package cn.fl.ref.fncprjbscinfo.controller;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.DecimalUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.capital.service.ICapAdvRuleInfoService;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.ref.asspackinfo.service.IAssPackInfoService;
import cn.fl.ref.asspackinfo.transform.AssPackListVOTransform;
import cn.fl.ref.asspackinfo.vo.AssPackListVO;
import cn.fl.ref.crbaseinfo.service.ICrBaseInfoService;
import cn.fl.ref.crbaseinfo.vo.CrBaseInfoVO;
import cn.fl.ref.fncpreabslim.service.IFncPreAbsLimService;
import cn.fl.ref.fncpreabslim.vo.FncPreAbsLimVO;
import cn.fl.ref.fncprjbscinfo.service.IFncPrjBscInfoService;
import cn.fl.ref.fncprjbscinfo.service.IFncPrjPayPlanService;
import cn.fl.ref.fncprjbscinfo.service.IFncPrjSplitAccountService;
import cn.fl.ref.fncprjbscinfo.transform.FncPrjBscInfoVOTransform;
import cn.fl.ref.fncprjbscinfo.util.UpbaaDate;
import cn.fl.ref.fncprjbscinfo.util.XirrData;
import cn.fl.ref.fncprjbscinfo.vo.FncPrjBscInfoVO;
import cn.fl.ref.fncprjbscinfo.vo.FncPrjPayPlanVO;
import cn.fl.ref.fncprjbscinfo.vo.FncPrjSplitAccountVO;
import cn.fl.ref.fncprjdrawmon.vo.FncPrjDrawMonVO;
import cn.fl.ref.fncprjfstpyinfo.service.IFncPrjFstpyInfoService;
import cn.fl.ref.fncprjfstpyinfo.vo.FncPrjDetailVO;
import cn.fl.ref.fncprjfstpyinfo.vo.FncPrjFstpyInfoVO;
import cn.fl.ref.fncprjpaysch.service.IFncPrjPaySchService;
import cn.fl.ref.fncprjpaysch.vo.FncPrjPaySchDVO;
import cn.fl.ref.fncprjpaysch.vo.FncPrjPaySchMVO;
import cn.fl.ref.fribaseinfo.service.IFriBaseInfoService;
import cn.fl.ref.fribaseinfo.transform.FriBaseFlowVOTransform;
import cn.fl.ref.fribaseinfo.vo.BankAccInfoVO;
import cn.fl.ref.fribaseinfo.vo.FriBaseFlowVO;
import cn.fl.ref.fribaseinfo.vo.FriBaseInfoVO;
import cn.fl.ref.scmbaseinfo.service.IScmBaseInfoService;
import cn.fl.ref.scmbaseinfo.vo.ScmBaseInfoVO;
import cn.fl.system.condition.SysBkAccInfoQueryCondition;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysBkAccInfoService;
import cn.fl.system.service.ISysBkInfoService;
import cn.fl.system.vo.SysBkAccInfoVO;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import fl.flow.facade.flow.dto.FlowStartedDTO;
import fl.ref.asspackinfo.condition.AssPackInfoQueryCondition;
import fl.ref.asspackinfo.constant.AssPackInfoConstant;
import fl.ref.asspackinfo.dto.AssPackInfoDTO;
import fl.ref.asspackinfo.dto.AssPackListDTO;
import fl.ref.asspackinfo.dto.FncPrjPayRltvInfo2DTO;
import fl.ref.asspackinfo.dto.FncPrjPayRltvInfoDTO;
import fl.ref.asspackinfo.service.IAssPackInfoApiService;
import fl.ref.crbaseinfo.constant.CrBaseInfoConstant;
import fl.ref.fncprjbscinfo.condition.FncPrjBscInfoQueryCondition;
import fl.ref.fncprjbscinfo.condition.FncPrjPayPlanQueryCondition;
import fl.ref.fncprjbscinfo.condition.FncPrjSplitAccountQueryCondition;
import fl.ref.fncprjbscinfo.constant.FncPrjBaseInfoConstant;
import fl.ref.fncprjbscinfo.dto.FncPrjBscInfoDTO;
import fl.ref.fncprjfstpyinfo.condition.FncPrjFstpyInfoQueryCondition;
import fl.ref.fncprjpaysch.dto.FncPrjPayInsDTO;
import fl.ref.fncprjpaysch.service.IFncPrjPayInsApiService;
import fl.ref.fribaseinfo.condition.BankAccInfoQueryCondition;
import fl.ref.fribaseinfo.condition.FriBaseInfoQueryCondition;
import fl.ref.fribaseinfo.constant.FriBaseInfoConstant;
import fl.ref.fribaseinfo.dto.BankAccInfoDTO;
import fl.ref.fribaseinfo.dto.FriBaseFlowDTO;
import fl.ref.fribaseinfo.service.IBankAccInfoApiService;
import fl.ref.scmbaseinfo.condition.ScmBaseInfoQueryCondition;
import fl.ref.scmbaseinfo.constant.ScmInfoConstant;
import fl.ref.scmbaseinfo.constant.ScmInfoConstant.ScmSt;


/**
 * @Description: 项目基本信息
 */
@Controller
@RequestMapping("/rfbuss/fncprjbscinfo")
public class FncPrjBscInfoController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(FncPrjBscInfoController.class);
  
	@Autowired
	IFncPrjBscInfoService fncPrjBscInfoService;
	
	@Autowired
	IFriBaseInfoService  friBaseInfoService;
	
	@Autowired
	ICrBaseInfoService crBaseInfoService;
	@Autowired
	IScmBaseInfoService scmBaseInfoService;
	
	@Autowired
	IFncPrjPayPlanService  fncPrjPayPlanService;
	
	@Autowired
	IFncPrjPaySchService fncPrjPaySchService;
	
	@Autowired
	private IAssPackInfoService assPackInfoService;
	
	@Autowired
	private IFncPrjFstpyInfoService fncPrjFstpyInfoService;
	/**
	 * 字典服务层BEAN
	 */
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;
	
	/**
	 * 融资机构银行帐号信息
	 */
	@Autowired
	private IBankAccInfoApiService bankAccInfoApiService;
	//垫款规则
	@Autowired
	private ICapAdvRuleInfoService capAdvRuleInfoService;
	
	@Autowired
	private ISysBkInfoService sysBkInfoService;
	/**
	 * 狮桥支付银行账户
	 */
	@Autowired
	private ISysBkAccInfoService sysBkAccInfoService;
	@Autowired
	private IAssPackInfoApiService assPackInfoApiService;
	@Autowired
	private IFncPreAbsLimService fncPreAbsLimService;
	private static int t_width = 256*14;  
    //默认字体  
    private static String t_excelfont = "微软雅黑";  
    @Autowired
	private IFncPrjSplitAccountService fncPrjSplitAccountService;
    @Autowired
	private IFncPrjPayInsApiService fncPrjPayInsApiService;
	
    
    
    /**
	 * 根据id查询资产包和支付表关联信息
	 * @param request
	 * @param response
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/fncPrjPayRltvInfo.do", method = {RequestMethod.GET})
	@ResponseBody
	public Object fncPrjPayRltvInfo(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String id = request.getParameter("id");			//资产包id
		String fncCrdnlt = request.getParameter("fncCrdnlt");		//融资基数
		String stdt = request.getParameter("stdt");			//计划融资日期开始时间
		String eddt = request.getParameter("eddt");			//计划融资日期结束时间
		String cstTypCd = request.getParameter("cstTypCd");			//客户类型
		String buOrgCd = request.getParameter("buOrgCd");			//所属事业部
		String isMortgage = request.getParameter("isMortgage");		//是否办理抵押
		String isInsurance = request.getParameter("isInsurance");		//是否有保险
		String leaseTermMinQ = request.getParameter("leaseTermMinQ");	//租赁期数开始
		String leaseTermMaxQ = request.getParameter("leaseTermMaxQ");	//租赁期数结束
		String surplusLeaseTermMinQ = request.getParameter("surplusLeaseTermMinQ");		//剩余租赁期数开始
		String surplusLeaseTermMaxQ = request.getParameter("surplusLeaseTermMaxQ");		//剩余租赁期数结束
		String stDtQ = request.getParameter("stDtQ");		//起租日期开始
		String edDtQ = request.getParameter("edDtQ");		//起租日期结束
		String ovdDaysMin = request.getParameter("ovdDaysMin");		//逾期天数开始
		String ovdDaysMax = request.getParameter("ovdDaysMax");		//逾期天数结束
		
		if(StringUtils.isEmpty(id)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"资产包id不能为空!");
		}
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		
		AssPackInfoQueryCondition condition = new AssPackInfoQueryCondition();
		if (StringUtils.isNotEmpty(id)) {
			condition.setId(Long.valueOf(id.trim()));
			condition.setIsEdit(1);
		}
		if (StringUtils.isNotEmpty(fncCrdnlt)) {
			condition.setFncCrdnlt(Integer.parseInt(fncCrdnlt.trim()));
		}
		if (StringUtils.isNotEmpty(stdt)) {
			condition.setStdt(DateUtils.formatStringToDate(stdt.trim(), DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(eddt)) {
			condition.setEddt(DateUtils.formatStringToDate(eddt.trim(), DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(cstTypCd)) {
			condition.setCstTypCd(cstTypCd.trim());
		}
		if (StringUtils.isNotEmpty(buOrgCd)) {
			condition.setBuOrgCd(buOrgCd);
		}
		if (StringUtils.isNotEmpty(isMortgage)) {
			condition.setIsMortgage(isMortgage.trim());
		}
		if (StringUtils.isNotEmpty(isInsurance)) {
			condition.setIsInsurance(isInsurance.trim());
		}
		if (StringUtils.isNotEmpty(leaseTermMinQ)) {
			condition.setLeaseTermMinQ(Integer.parseInt(leaseTermMinQ.trim()));
		}
		if (StringUtils.isNotEmpty(leaseTermMaxQ)) {
			condition.setLeaseTermMaxQ(Integer.parseInt(leaseTermMaxQ.trim()));
		}
		if (StringUtils.isNotEmpty(surplusLeaseTermMinQ)) {
			condition.setSurplusLeaseTermMinQ(Integer.parseInt(surplusLeaseTermMinQ.trim()));
		}
		if (StringUtils.isNotEmpty(surplusLeaseTermMaxQ)) {
			condition.setSurplusLeaseTermMaxQ(Integer.parseInt(surplusLeaseTermMaxQ.trim()));
		}
		if (StringUtils.isNotEmpty(stDtQ)) {
			condition.setStDtQ(DateUtils.formatStringToDate(stDtQ, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(edDtQ)) {
			condition.setEdDtQ(DateUtils.formatStringToDate(edDtQ, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(ovdDaysMin)) {
			condition.setOvdDaysMin(Integer.parseInt(ovdDaysMin.trim()));
		}
		if (StringUtils.isNotEmpty(ovdDaysMax)) {
			condition.setOvdDaysMax(Integer.parseInt(ovdDaysMax.trim()));
		}
		condition.setFinancingAmount(new BigDecimal(0));
		
		condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
		condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		page.setCondition(condition);
		
		Pager resultPager = this.assPackInfoService.searchPaySchInfoList(page);
		List<AssPackListDTO> dtoList = (List<AssPackListDTO>)resultPager.getResultList();
		List<AssPackListVO> voList = AssPackListVOTransform.toVOList(dtoList);
		ListPageVO<AssPackListVO> listPage = new ListPageVO<AssPackListVO>(voList,resultPager.getTotalCount());

		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(resultPager), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
    
    
    
    
	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		BaseLogUtils.error(logger, "toListPage", "加载crbaseinfo列表页面.");
	//	//logger.info("加载crbaseinfo列表页面.");
	//	String fncInsId  = request.getParameter("fncInsId");
	//	String fncInsNm  = request.getParameter("fncInsNm");
	//	String fncInsShort  = request.getParameter("fncInsShort");
		List<FriBaseInfoVO>  friList = null;
		try {
			FriBaseInfoQueryCondition friqc = new FriBaseInfoQueryCondition();
//			friqc.setInsUseCd("1");
			friList=friBaseInfoService.searchList(friqc);
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toListPage", "异常"+e.getMessage(), e);
		}
		
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncprjbscinfoList");
	//	view.addObject("fncInsId", fncInsId);
	//	view.addObject("fncInsNm", fncInsNm);
	//	view.addObject("fncInsShort", fncInsShort);
		view.addObject("frilist",JSON.toJSONString(friList));
		return view;
	}
	
	
	/**
	 * 初始化列表
	 * @param request
	 * @param response
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
	    String checkflag= request.getParameter("checkflag");
	
		String id = request.getParameter("id");
		String fncprjnm=request.getParameter("fncprjnm");
		String fncinsid=request.getParameter("fncinsid");
		String prjstcd=request.getParameter("prjstcd");
		String expwddateend=request.getParameter("expwddateend");
		String expwddatebegin=request.getParameter("expwddatebegin");
		String isAdv=request.getParameter("isAdv");
		String isSAdv=request.getParameter("isSAdv");
		String transst=request.getParameter("transst");//add  到账状态 by gengchunlan 20180222
		Pager page = new Pager();

		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		FncPrjBscInfoQueryCondition qc=new FncPrjBscInfoQueryCondition();
		if(StringUtils.isNotEmpty(checkflag)){
			if(checkflag.equals("1")){
				//List<Long> a=new ArrayList<Long>();
				//a.add(5L);
				//a.add(6L);
				//qc.setFncprjstcds(a);
				qc.setFncprjstcd(5);
			}
		}
	
		if (StringUtils.isNotEmpty(id)) {
			qc.setId(Long.parseLong(id));
		}
		if (StringUtils.isNotEmpty(fncprjnm)) {
			qc.setFncprjnm(fncprjnm);
		}
		if (StringUtils.isNotEmpty(fncinsid)) {
			qc.setFncinsid(fncinsid);
		}
		if (StringUtils.isNotEmpty(prjstcd)) {
			qc.setFncprjstcd1(Integer.parseInt(prjstcd));
		}
		if (StringUtils.isNotEmpty(isAdv)) {
			qc.setIsAdv(isAdv);
		}
		if (StringUtils.isNotEmpty(isSAdv)) {
			qc.setIsSAdv(isSAdv);
		}
		if (StringUtils.isNotEmpty(expwddateend)) {
			 
	          qc.setExpwddateend(DateUtils.formatStringToDate(expwddateend,DateUtils.YYYY_MM_DD));
				
			}
		if (StringUtils.isNotEmpty(expwddatebegin)) {
			 
	          qc.setExpwddatebegin(DateUtils.formatStringToDate(expwddatebegin,DateUtils.YYYY_MM_DD));
				
			}
		if (StringUtils.isNotEmpty(transst)) {//add  到账状态 by gengchunlan 20180222
			qc.setTransst(Integer.valueOf(transst));
		}
		//大于项目状态的
		String fncprjstcd=request.getParameter("fncprjstcd");
		if (StringUtils.isNotEmpty(fncprjstcd)) {
			qc.setFncprjstcd(Integer.parseInt(fncprjstcd));
		}
		page.setCondition(qc);
		Pager pager = this.fncPrjBscInfoService.searchListPage(page);
		List<FncPrjBscInfoVO> list = FncPrjBscInfoVOTransform.toVOList((List<FncPrjBscInfoDTO>) pager.getResultList());
		this.setListVOWithDicInfo(list);
		ListPageVO<FncPrjBscInfoVO> listPage = new ListPageVO<FncPrjBscInfoVO>(list, pager.getTotalCount());
		
		FriBaseInfoQueryCondition friqc = new FriBaseInfoQueryCondition();
		friqc.setInsUseCd("1");
		//List<FriBaseInfoVO>  friList=friBaseInfoService.searchList(friqc);
		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}

	
	/**
	 * 根据名字获取项目信息
	 * @param request
	 * @param response
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getprjbyname.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getprjbyname(HttpServletRequest request, HttpServletResponse response) {
		String fncprjnm=request.getParameter("fncprjnm");
		String id=request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO,
				"找不到其他该项目名");
		FncPrjBscInfoQueryCondition qc=new FncPrjBscInfoQueryCondition();
		if (StringUtils.isNotEmpty(fncprjnm)) {
			qc.setFncprjnm(fncprjnm);
		}
		int mes=1;
		List<FncPrjBscInfoVO> list = this.fncPrjBscInfoService.searchList(qc);
                  for (FncPrjBscInfoVO fncPrjBscInfoVO : list) {
					if(!id.equals(fncPrjBscInfoVO.getId().toString())){
						result.setSuccess(BaseConstant.IS_YESNO_YES);
						result.setInfo("该项目名已存在");
						return result;
					}
				}
        //lxb 校验机构批次号
        String limId=request.getParameter("limId");
        if (StringUtils.isNotEmpty(limId)) {
        	qc.setFncprjnm(null);
        	qc.setLimId(new Long(limId));
        	list = this.fncPrjBscInfoService.searchList(qc);
            for (FncPrjBscInfoVO fncPrjBscInfoVO : list) {
				if(fncPrjBscInfoVO.getFncprjstcd()!=14
						&& !id.equals(fncPrjBscInfoVO.getId().toString())){
					result.setSuccess(BaseConstant.IS_YESNO_YES);
					result.setInfo("该项目的机构帐号批次已存在");
					return result;
				}
			}
        }
		BaseLogUtils.info(logger, "searchList", "查询数据完成. DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
		return result;
	}

	/**
	 * 到项目新增修改页面
	 */
	@RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");
		String currentTabid=request.getParameter("currentTabid");

//		Pager page1 = new Pager();
//		page1.setEveryPage(100000);
//		Pager page2 = new Pager();
//		page2.setEveryPage(100000);
		FriBaseInfoQueryCondition friqc = new FriBaseInfoQueryCondition();
//		CrBaseInfoQueryCondition   crqc= new CrBaseInfoQueryCondition();
		ScmBaseInfoQueryCondition scmqc= new ScmBaseInfoQueryCondition();
//		crqc.setCrStQ(CrBaseInfoConstant.CR_BSC_INFO_CR_ST_PASS);
		friqc.setInsSts(FriBaseInfoConstant.FRI_BASE_INFO_INS_STS_PASS);
//		friqc.setInsUseCd("1");
//		scmqc.setFncScmStcd(3);
//		page1.setCondition(crqc);
//		page2.setCondition(scmqc);
		List<FriBaseInfoVO>  friList=friBaseInfoService.searchList(friqc);
//		Pager crpage=crBaseInfoService.searchListPage(page1);
//		Pager scmpage=scmBaseInfoService.searchListPage(page2);
		scmqc.setFncScmStcd(3);
		scmqc.setFncPrjdId("1");
		if(StringUtils.isNotEmpty(id)){
			scmqc.setFncPrjdId(id);
		}
		List<ScmBaseInfoVO>  scmList = this.scmBaseInfoService.selectBscLstByCondition(scmqc);
		//List<ScmBaseInfoVO>  scmList= new ArrayList<ScmBaseInfoVO>();
//		List<CrBaseInfoVO>  crList=	new ArrayList<CrBaseInfoVO>();
			
//		if(scmpage !=null){
//			for (ScmBaseInfoVO vo:ScmBaseInfoVOTransform.toVOList((List<ScmBscInfoDTO>)scmpage.getResultList())) {
//		if(CollectionUtils.isNotEmpty(scmList2)){
//			for (ScmBaseInfoVO vo:scmList2) {
//				if (vo.getScmSt()!=null && vo.getScmSt()==3) {
//					scmList.add(vo);
//				}
//				
//			}
//		}
		
//		if(crpage !=null){
//			crList=(List<CrBaseInfoVO>)crpage.getResultList();
//		}
		
		List<KeyValueVO> countrylist=this.getKvList(FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_CTY);
		List<KeyValueVO> bustypelist=this.getKvList(FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_BUS_TYPE);
		List<KeyValueVO> firtypelist=this.getKvList(FriBaseInfoConstant.FUND_RAS_INS_BASE_INFO_INS_TYPE_CD);	
		List<KeyValueVO> crsbjlist=this.getKvList(CrBaseInfoConstant.CR_BSC_INFO_CR_SBJ);
		List<KeyValueVO> payMayList=this.getKvList(FriBaseInfoConstant.FNC_PAY_MAY);//再融资支付渠道
		List<KeyValueVO> payMayBackList=this.getKvList(FriBaseInfoConstant.FNC_PAY_MAY_BACK);//再融资支付渠道备用
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjBscInfoAdd");
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			view.addObject("id", id);
			view.addObject("fncprjnm", fncPrjBscInfoVO.getFncprjnm());
			view.addObject("bustype", fncPrjBscInfoVO.getBustype());
			view.addObject("country", fncPrjBscInfoVO.getCountry());
			view.addObject("fncinsid", fncPrjBscInfoVO.getFncinsid());
			view.addObject("fncscmid", fncPrjBscInfoVO.getFncscmid());
			view.addObject("instypecd", fncPrjBscInfoVO.getInstypecd());
			view.addObject("fncfiamt", DecimalUtils.convertFenToYuan(fncPrjBscInfoVO.getFncfiamt())  );
			view.addObject("fncprjamt",DecimalUtils.convertFenToYuan(fncPrjBscInfoVO.getFncprjamt()) );
			view.addObject("paySchCount",fncPrjBscInfoVO.getPaySchCount() );
			view.addObject("fncPrjBscInfoVO",fncPrjBscInfoVO );
			if(CollectionUtils.isNotEmpty(fncPrjBscInfoVO.getFncPrjSplitAccountList())){
				view.addObject("splitArrayJSON", JSONArray.toJSONString(fncPrjBscInfoVO.getFncPrjSplitAccountList()));	
				BaseLogUtils.info(logger, "splitArrayJSON", "查询数据完成. splitArrayJSON:" + JSONArray.toJSONString(fncPrjBscInfoVO.getFncPrjSplitAccountList()), CurrentThreadContext.getCurrentUserName());
			}
			//type name = new type(arguments);
			if (fncPrjBscInfoVO.getBankAccInfoId()!=null) {
				BankAccInfoVO vo = this.friBaseInfoService.selectAccById(fncPrjBscInfoVO.getBankAccInfoId(), CurrentThreadContext.getCurrentSysCd(),
						CurrentThreadContext.getCurrentOrgCd());
				view.addObject("zybank", vo);
			}
			if (fncPrjBscInfoVO.getSysBkAccInfoId()!=null) {
				SysBkAccInfoVO vo = this.sysBkAccInfoService.selectById(fncPrjBscInfoVO.getSysBkAccInfoId());
				if (vo.getBkId()!=null) {
					vo.setSysBkInfoVO(this.sysBkInfoService.selectById(vo.getBkId()));
				}
				view.addObject("mybank", vo);
			}
//			CapPrjRuleRQueryCondition qc=new CapPrjRuleRQueryCondition();
//			qc.setFncPrjId(Long.parseLong(id));
//			qc.setIsValid(1);
//			List<CapAdvRuleInfoDTO>  list =capAdvRuleInfoService.selectAdvRuleInfoByPrjId(qc);
//			if (list!=null && list.size()>0) {
//				CapAdvRuleInfoDTO rowdata=list.get(0);
//				view.addObject("rule", rowdata);
//			}
			
		}

		view.addObject("frilist",JSON.toJSONString(friList));
		view.addObject("firtypelist",JSON.toJSONString(firtypelist));
//		view.addObject("crList",JSON.toJSONString(crList));
		view.addObject("scmlist",JSON.toJSONString(scmList));
		view.addObject("countrylist",JSON.toJSONString(countrylist));
		view.addObject("bustypelist",JSON.toJSONString(bustypelist));
		view.addObject("crsbjlist",JSON.toJSONString(crsbjlist));
		view.addObject("payMayList",payMayList);//再融资支付渠道
		view.addObject("currentTabid",currentTabid);
		view.addObject("payMayBackJSON", JSON.toJSON(payMayBackList));
		BaseLogUtils.info(logger, "toAddPage", "查询数据完成. DATA:" + JSONObject.toJSONString(friList), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	
	/**
	 * 授信主体下拉框选项
	 */
	@RequestMapping(value = "/getCrsbjList.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public  List<KeyValueVO> getCrsbjList(HttpServletRequest request, HttpServletResponse response) {
		//授信主体
		String scmid=request.getParameter("scmid");
		ScmBaseInfoVO scmvo= this.scmBaseInfoService.selectById(Long.parseLong(scmid));
		String crId=scmvo.getCrId();
		CrBaseInfoVO crvo= new CrBaseInfoVO();
		List<KeyValueVO> crsbjList=new ArrayList<KeyValueVO>();
		List<KeyValueVO> crsbjList0 = this.getKvList(CrBaseInfoConstant.CR_BSC_INFO_CR_SBJ);
		if(crId !=null){
			crvo=this.crBaseInfoService.selectByCrId(crId);
		}
	
		String crsbj=crvo.getCrSbj();
		if(null!=crsbj){
		String[] crsbjs=crsbj.split(";");
		
		for (KeyValueVO keyValueVO : crsbjList0) {
			for (int i = 0; i < crsbjs.length; i++) {
				if(keyValueVO.getKey().equals(crsbjs[i])){
					crsbjList.add(keyValueVO);
					break;
				}
			}
		}
		}
		if(crsbjList.size()==0){
			crsbjList=crsbjList0;
		}
		BaseLogUtils.info(logger, "getCrsbjList", "查询数据完成. DATA:" + JSONObject.toJSONString(crsbjList), CurrentThreadContext.getCurrentUserName());
		return crsbjList;
	}
	
	/**
	 * 业务类型下拉框选项
	 */
	@RequestMapping(value = "/getBusTypeList.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public  List<KeyValueVO> getBusTypeList(HttpServletRequest request, HttpServletResponse response) {
		String busType=request.getParameter("busType");	
		List<KeyValueVO> bustypelist = new ArrayList<KeyValueVO>();
		List<KeyValueVO> list = this.getKvList(FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_BUS_TYPE);
		for (KeyValueVO keyValueVO : list) {
			
				if(keyValueVO.getKey().equals(busType)){
					bustypelist.add(keyValueVO);
					break;
				}
		
		}
		if(bustypelist.size()==0){
			bustypelist=list;
		}
		BaseLogUtils.info(logger, "getBusTypeList", "查询数据完成. DATA:" + JSONObject.toJSONString(bustypelist), CurrentThreadContext.getCurrentUserName());
		return bustypelist;
	}
	/**
	 * 审核状态下拉框选项
	 */
	@RequestMapping(value = "/getStcdList.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public  List<KeyValueVO> getStcdList(HttpServletRequest request, HttpServletResponse response) {
		List<KeyValueVO> stcdlist=this.getKvList(FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_ST_CD);
		BaseLogUtils.info(logger, "getStcdList", "查询数据完成. DATA:" + JSONObject.toJSONString(stcdlist), CurrentThreadContext.getCurrentUserName());
		return stcdlist;
	}
	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		String fncprjid = request.getParameter("fncprjid");
		
		String fncscmid = request.getParameter("fncscmid");
		
		String bustype = request.getParameter("bustype");
		
		String instypecd = request.getParameter("instypecd");
		
		String country = request.getParameter("country");
		
		String crsbj = request.getParameter("crsbj");
		
		String fncprjnm = request.getParameter("fncprjnm");
		
		String fncprjamt = request.getParameter("fncprjamt");
		
		String fncfiamt = request.getParameter("fncfiamt");
		
		String fncprjstcd = request.getParameter("fncprjstcd");
		
					
		
		
		String fncinsid = request.getParameter("fncinsid");
		
		String crtpsnecd = request.getParameter("crtpsnecd");
		
		String updpsnecdd = request.getParameter("updpsnecdd");
		
		String crttm = request.getParameter("crttm");
		
		String updtm = request.getParameter("updtm");
		
		String rmrk = request.getParameter("rmrk");
		
		String isvalid = request.getParameter("isvalid");
		
		String isdel = request.getParameter("isdel");
		
		String transst = request.getParameter("transst");
		
		String transam = request.getParameter("transam");
		
		String transbank = request.getParameter("transbank");
		
		String transacc = request.getParameter("transacc");
		
		String wthrddct = request.getParameter("wthrddct");
		
		String expint = request.getParameter("expint");
		
		String expwdamt = request.getParameter("expwdamt");
		
		String fstpyaccno = request.getParameter("fstpyaccno");
		
		String fstpybank = request.getParameter("fstpybank");
		
		String fstpydepbank = request.getParameter("fstpydepbank");
		
		String fstpydepadd = request.getParameter("fstpydepadd");
		
		String transtm = request.getParameter("transtm");
		
		String acFiAmt = request.getParameter("acFiAmt");
		
		String fstpyamt = request.getParameter("fstpyamt");
		
		String transflag= request.getParameter("transflag");
		
		String dcnRate= request.getParameter("dcnRate");
		
		String paySchCount= request.getParameter("paySchCount");
		
		String expwdacc= request.getParameter("expwdacc");
		
		String expwdbank=request.getParameter("expwdbank");
		
		String expwddate=request.getParameter("expwddate");
		
		String myCompMoney = request.getParameter("myCompMoney");//我司金额
		String isSplitAccount = request.getParameter("isSplitAccount");//是否分账
		String splitAccountArray = request.getParameter("splitAccountArray");//分账账户
		String isSplitMsg = request.getParameter("isSplitMsg");//是否分账短信提醒
		FncPrjBscInfoVO  entity=new FncPrjBscInfoVO();
		

		
		if (StringUtils.isNotEmpty(transtm)) {
 
	          entity.setTranstm(DateUtils.formatStringToDate(transtm,DateUtils.YYYY_MM_DD));
				
			}
		
		if (StringUtils.isNotEmpty(expwddate)) {
			 
	          entity.setExpwddate(DateUtils.formatStringToDate(expwddate,DateUtils.YYYY_MM_DD));
				
			}
		if (StringUtils.isNotEmpty(expwdacc)) {
			 
	          entity.setExpwdacc(expwdacc);
				
			}
		if (StringUtils.isNotEmpty(expwdbank)) {
			 
	          entity.setExpwdbank(expwdbank);
				
			}
		if (StringUtils.isNotEmpty(fncprjid)) {
          entity.setFncprjid(fncprjid);
			
		}
		if (StringUtils.isNotEmpty(fncscmid)) {
			entity.setFncscmid(Long.parseLong(fncscmid));
		}
		if (StringUtils.isNotEmpty(bustype)) {
          entity.setBustype(bustype);
			
		}
		if (StringUtils.isNotEmpty(instypecd)) {
          entity.setInstypecd(instypecd);
			
		}
		if (StringUtils.isNotEmpty(country)) {
          entity.setCountry(country);
			
		}
		if (StringUtils.isNotEmpty(crsbj)) {
          entity.setCrsbj(crsbj);
			
		}
		if (StringUtils.isNotEmpty(fncprjnm)) {
          entity.setFncprjnm(fncprjnm);
			
		}
		
		
		
		if (StringUtils.isNotEmpty(paySchCount)) {
			
	          entity.setPaySchCount(Long.parseLong(paySchCount));
	          
				
			}
		////////////////////////金额////////////////////////////////////
		

		
		
		if (StringUtils.isNotEmpty(fstpyamt)) {
			 
	          entity.setFstpyamt(DecimalUtils.convertYuanToFen(Double.parseDouble(fstpyamt)));
				
			}
		
		if (StringUtils.isNotEmpty(fncprjamt)) {
			//DecimalUtils.convertFenToYuan(prjPrdBscInfoDTO.getInvAmt().longValue())
			entity.setFncprjamt(DecimalUtils.convertYuanToFen(Double.parseDouble(fncprjamt)));	
		}
		
		if (StringUtils.isNotEmpty(acFiAmt)) {
			 
	          entity.setAcFiAmt(DecimalUtils.convertYuanToFen(Double.parseDouble(acFiAmt)));
	        
			}
		
		 fncprjamt=fncfiamt+"";
		if (StringUtils.isNotEmpty(fncfiamt)) {
			entity.setFncfiamt(DecimalUtils.convertYuanToFen(Double.parseDouble(fncfiamt)));	
			  if(StringUtils.isNotEmpty(id)){
	        	  FncPrjBscInfoVO vo1=this.fncPrjBscInfoService.selectById(Long.parseLong(id));
	        	  if(vo1.getDcnRate()!=null){
	        		  entity.setFncprjamt(DecimalUtils.convertYuanToFen(Double.parseDouble(fncprjamt)*vo1.getDcnRate()));  
	        	  }
	          }
		}
		if (StringUtils.isNotEmpty(expwdamt)) {
			entity.setExpwdamt(DecimalUtils.convertYuanToFen(Double.parseDouble(expwdamt)));		
		}	
		
		if (StringUtils.isNotEmpty(expwdamt)) {
			entity.setExpwdamt(DecimalUtils.convertYuanToFen(Double.parseDouble(expwdamt)));		
		}
		if (StringUtils.isNotEmpty(transam)) {
			entity.setTransam(DecimalUtils.convertYuanToFen(Double.parseDouble(transam)));		
		}
		if (StringUtils.isNotEmpty(fstpydepadd)) {
	          entity.setFstpydepadd(DecimalUtils.convertYuanToFen(Double.parseDouble(fstpydepadd))+"");	
		}
          ////////////////////////金额end////////////////////////////////////
		
		if (StringUtils.isNotEmpty(fncprjstcd)) {
			entity.setFncprjstcd(Integer.parseInt(fncprjstcd));		
		}
		if (StringUtils.isNotEmpty(fncinsid)) {
          entity.setFncinsid(fncinsid);
			
		}
		if (StringUtils.isNotEmpty(crtpsnecd)) {
          entity.setCrtpsnecd(crtpsnecd);
			
		}
		if (StringUtils.isNotEmpty(updpsnecdd)) {
          entity.setUpdpsnecdd(updpsnecdd);
			
		}
		if (StringUtils.isNotEmpty(id)) {
			entity.setUpdtm(new Date());
		}else{
			entity.setCrttm(new Date());
		}
			
		if (StringUtils.isNotEmpty(rmrk)) {
          entity.setRmrk(rmrk);
			
		}
		
		
		
		
		entity.setTransst(0);
		if (StringUtils.isNotEmpty(transst)) {
			
		}
		if (StringUtils.isNotEmpty(transam)) {
			
		}
		
		if (StringUtils.isNotEmpty(transbank)) {
          entity.setTransbank(transbank);
			
		}
		if (StringUtils.isNotEmpty(transacc)) {
          entity.setTransacc(transacc);
			
		}
		if (StringUtils.isNotEmpty(wthrddct)) {
          entity.setWthrddct(wthrddct);
			
		}
		if (StringUtils.isNotEmpty(expint)) {
			
		}
		if (StringUtils.isNotEmpty(expwdamt)) {
			
		}
		if (StringUtils.isNotEmpty(fstpyaccno)) {
          entity.setFstpyaccno(fstpyaccno);
			
		}
		if (StringUtils.isNotEmpty(fstpybank)) {
          entity.setFstpybank(fstpybank);
			
		}
		if (StringUtils.isNotEmpty(fstpydepbank)) {
          entity.setFstpydepbank(fstpydepbank);
			
		}
		
		if (StringUtils.isNotEmpty(request.getParameter("isAdv"))) {
	          entity.setIsAdv(request.getParameter("isAdv"));
		}
		if (StringUtils.isNotEmpty(request.getParameter("isSAdv"))) {
	          entity.setIsSAdv(request.getParameter("isSAdv"));
		}
		if (StringUtils.isNotEmpty(request.getParameter("sysBkAccInfoId"))) {
	          entity.setSysBkAccInfoId(Long.parseLong(request.getParameter("sysBkAccInfoId")));
		}
		if (StringUtils.isNotEmpty(request.getParameter("bankAccInfoId"))) {
	          entity.setBankAccInfoId(Long.parseLong(request.getParameter("bankAccInfoId")));
		}
		if (StringUtils.isNotEmpty(request.getParameter("capAdvRuleInfoId"))) {
	          entity.setCapAdvRuleInfoId(Long.parseLong(request.getParameter("capAdvRuleInfoId")));
		}
		if (StringUtils.isNotEmpty(request.getParameter("isOut"))) {
	          entity.setIsOut(request.getParameter("isOut"));
		}
		if (StringUtils.isNotEmpty(request.getParameter("contractAudit"))) {
	          entity.setContractAudit(request.getParameter("contractAudit"));
		}
		if (StringUtils.isNotEmpty(myCompMoney)) {
	          entity.setMyCompMoney(DecimalUtils.convertYuanToFen(Double.parseDouble(myCompMoney)));
		}
		if (StringUtils.isNotEmpty(request.getParameter("limId"))) {
	          entity.setLimId(Long.parseLong(request.getParameter("limId")));
		}
		if (StringUtils.isNotEmpty(isSplitAccount)) {//是否分账
	          entity.setIsSplitAccount(isSplitAccount);
		}
		if (StringUtils.isNotEmpty(isSplitMsg)) {//是否分账
	          entity.setIsSplitMsg(isSplitMsg);
		}
		
		entity.setIsvalid(BaseConstant.IS_YESNO_YES); // 有效
		entity.setIsdel(BaseConstant.IS_YESNO_NO); // 未删除
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
		Long mainId;
		//if(StringUtils.isNotEmpty(fncscmid)){
		//ScmBaseInfoVO scmvo=this.scmBaseInfoService.selectById(Long.parseLong(fncscmid));
		//CrBaseInfoVO crbvo = scmBaseInfoService.selectByCrId(scmvo.getCrId());
		//entity.setCrsbj(crbvo.getCrSbj());
		//}
		// 分账账户信息
		if(StringUtils.isNotBlank(splitAccountArray)) {
			JSONArray splitAccountJson = JSONArray.parseArray(splitAccountArray);
			List<FncPrjSplitAccountVO> accountVOList = new ArrayList<>();
			if ( !splitAccountArray.isEmpty() && splitAccountJson!=null && splitAccountJson.size() > 0) {
				for (int i = 0; i < splitAccountJson.size(); i++) {
					FncPrjSplitAccountVO accountVO = JSONObject.toJavaObject(splitAccountJson.getJSONObject(i), FncPrjSplitAccountVO.class);
					accountVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
					accountVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
					accountVOList.add(accountVO);
				}
				entity.setFncPrjSplitAccountList(accountVOList);
			}
		}
		try {
			if(StringUtils.isEmpty(id)){
				entity.setFncprjid(entity.getCountry()+entity.getCrsbj()+entity.getBustype()+entity.getInstypecd());
				 entity.setFncprjstcd(0);
				 entity.setCrtpsnecd(CurrentThreadContext.getCurrentUserId().toString()); // 新增人
			     entity.setCrttm(new Date()); // 新增时间
				 mainId = this.fncPrjBscInfoService.add(entity);	
					result.setInfo("新增成功!");
			}else{
				if(StringUtils.isNotEmpty(entity.getInstypecd())){
					
					entity.setFncprjid(entity.getCountry()+entity.getCrsbj()+entity.getBustype()+entity.getInstypecd()+id);
				}
					
			
			    entity.setId(Long.parseLong(id));
			    entity.setUpdpsnecdd(CurrentThreadContext.getCurrentUserId().toString()); // 修改人
				entity.setUpdtm(new Date()); // 修改时间
			
				//付款管理
				if(StringUtils.isNotEmpty(transflag) && transflag.equals("1")){
					String fstpyArray = request.getParameter("fstpyArray"); 
					String transmess = request.getParameter("transmess"); 
					JSONArray fstpyJsonArray = JSONArray.parseArray(fstpyArray);
					JSONArray transmessJsonArray = JSONArray.parseArray(transmess);
					
					List<FncPrjFstpyInfoVO> fncPrjFstpyInfoVOs = new ArrayList<>();
					List<FncPrjDrawMonVO> fncPrjDrawMonVOs = new ArrayList<>();
					if (transmessJsonArray.size() > 0) {
						for (int i = 0; i < transmessJsonArray.size(); i++) {
							FncPrjDrawMonVO fncPrjDrawMonVO = JSONObject.toJavaObject(transmessJsonArray.getJSONObject(i), FncPrjDrawMonVO.class);
							fncPrjDrawMonVO.setPrjId(Long.parseLong(id));;
							fncPrjDrawMonVOs.add(fncPrjDrawMonVO);
						}
					}
					this.fncPrjBscInfoService.modifyTranmess(fncPrjDrawMonVOs,Long.parseLong(id));
					if (fstpyJsonArray.size() > 0) {
						for (int i = 0; i < fstpyJsonArray.size(); i++) {
							FncPrjFstpyInfoVO fncPrjFstpyInfoVO = JSONObject.toJavaObject(fstpyJsonArray.getJSONObject(i), FncPrjFstpyInfoVO.class);
							fncPrjFstpyInfoVO.setFncPrjId(id);
							fncPrjFstpyInfoVOs.add(fncPrjFstpyInfoVO);
						}
					}
			
					//entity.setTransst(1);
					this.fncPrjBscInfoService.modifyfpy(fncPrjFstpyInfoVOs);	
					
					
				}
				this.fncPrjBscInfoService.modify(entity);
				result.setInfo("修改成功!");
				mainId=Long.parseLong(id);
				//保存垫款规则 lxb 2017-12-8
//				if ("1".equals(entity.getIsAdv())) {
//					CapPrjRuleRDTO ruleRDTO=new CapPrjRuleRDTO();
//					ruleRDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
//					ruleRDTO.setCrtTm(new Date());
//					ruleRDTO.setIsValid(1);
//					ruleRDTO.setAdvRuleId(entity.getCapAdvRuleInfoId());
//					ruleRDTO.setFncPrjId(mainId);
//					capAdvRuleInfoService.addAndModifyCapPrjRuleR(ruleRDTO);
//				}
				
			}
			String spFlag = request.getParameter("spFlag");//分账账户
			if(StringUtils.isNotBlank(spFlag)) {
				FncPrjBscInfoVO prjBsc=	fncPrjBscInfoService.selectById(mainId);
				if(CollectionUtils.isNotEmpty(prjBsc.getFncPrjSplitAccountList())){
					result.setInfo(JSONArray.toJSONString(prjBsc.getFncPrjSplitAccountList()));
					BaseLogUtils.info(logger, "再融资项目新增", "查询数据完成. splitArrayJSON:" + JSONArray.toJSONString(prjBsc.getFncPrjSplitAccountList()), CurrentThreadContext.getCurrentUserName());
				}
			}
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			result.setData(mainId);
			
			BaseLogUtils.info(logger, "add", "新增数据 ", CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "新增数据失败"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("新增失败!");
			BaseLogUtils.error(logger, "add", "新增数据失败"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		BaseLogUtils.info(logger, "add", "查询数据完成. DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		return result;
	}
	
	/**
	 * 到浏览页面
	 */
	@RequestMapping(value = "/toDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");
		String pflag = request.getParameter("pflag");
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjBscInfoDetail");
		view.addObject("pflag",pflag);
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id);  
				view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);
			//add  by gengchunlan 20180427
			if(fncPrjBscInfoVO.getCrId()!=null){//授信信息
				CrBaseInfoVO	crBaseInfoVO = this.crBaseInfoService.selectByCrId(fncPrjBscInfoVO.getCrId());
				Map<String, String> crstMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CrBaseInfoConstant.CR_BSC_INFO_CR_ST);
				if(crBaseInfoVO.getCrSt()!=null){//处理授信状态
					if(crstMap.containsKey(crBaseInfoVO.getCrSt().toString())){
						crBaseInfoVO.setCrStNm(crstMap.get(crBaseInfoVO.getCrSt().toString()));
					}
				}
				view.addObject("crBaseInfo", crBaseInfoVO);
			}
			if(fncPrjBscInfoVO.getFncscmid()!=null){//方案信息fncscmid
				ScmBaseInfoVO scmBaseInfo= scmBaseInfoService.selectById(fncPrjBscInfoVO.getFncscmid());	
				Map<String, String> scmMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), ScmInfoConstant.FNC_SCM_BSC_INFO_SCM_ST);
				if(scmBaseInfo.getScmSt()!=null){//方案状态
					if(scmMap.containsKey(scmBaseInfo.getScmSt().toString())){
						scmBaseInfo.setScmDes(scmMap.get(scmBaseInfo.getScmSt().toString()));
					}
				}
				view.addObject("scmBaseInfo", scmBaseInfo);
			}//end  by gengchunlan 20180427
		}
		List<KeyValueVO> payMayList=this.getKvList(FriBaseInfoConstant.FNC_PAY_MAY);//再融资支付渠道
		view.addObject("payMayList",payMayList);//再融资支付渠道
		BaseLogUtils.info(logger, "toDetailPage", "查询数据完成. DATA:" + JSONObject.toJSONString(id), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到浏览页面
	 */
	@RequestMapping(value = "/toDetailPage1.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toDetailPage1(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");
		
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjBscInfoDetail1");
		try {
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id);  
			view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);
			if (fncPrjBscInfoVO.getBankAccInfoId()!=null) {
				BankAccInfoVO vo = this.friBaseInfoService.selectAccById(fncPrjBscInfoVO.getBankAccInfoId(), CurrentThreadContext.getCurrentSysCd(),
						CurrentThreadContext.getCurrentOrgCd());
				view.addObject("zybank", vo);
			}
			if (fncPrjBscInfoVO.getSysBkAccInfoId()!=null) {
				SysBkAccInfoVO vo = this.sysBkAccInfoService.selectById(fncPrjBscInfoVO.getSysBkAccInfoId());
				if (vo.getBkId()!=null) {
					vo.setSysBkInfoVO(this.sysBkInfoService.selectById(vo.getBkId()));
				}
				view.addObject("mybank", vo);
			}
			//add  by gengchunlan 20180427
			if(fncPrjBscInfoVO.getCrId()!=null){//授信信息
				CrBaseInfoVO	crBaseInfoVO = this.crBaseInfoService.selectByCrId(fncPrjBscInfoVO.getCrId());
				Map<String, String> crstMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CrBaseInfoConstant.CR_BSC_INFO_CR_ST);
				if(crBaseInfoVO.getCrSt()!=null){//处理授信状态
					if(crstMap.containsKey(crBaseInfoVO.getCrSt().toString())){
						crBaseInfoVO.setCrStNm(crstMap.get(crBaseInfoVO.getCrSt().toString()));
					}
				}
				view.addObject("crBaseInfo", crBaseInfoVO);
			}
			if(fncPrjBscInfoVO.getFncscmid()!=null){//方案信息fncscmid
				ScmBaseInfoVO scmBaseInfo= scmBaseInfoService.selectById(fncPrjBscInfoVO.getFncscmid());	
				Map<String, String> scmMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), ScmInfoConstant.FNC_SCM_BSC_INFO_SCM_ST);
				if(scmBaseInfo.getScmSt()!=null){//方案状态
					if(scmMap.containsKey(scmBaseInfo.getScmSt().toString())){
						scmBaseInfo.setScmDes(scmMap.get(scmBaseInfo.getScmSt().toString()));
					}
				}
				view.addObject("scmBaseInfo", scmBaseInfo);
			}//end  by gengchunlan 20180427
			if (fncPrjBscInfoVO.getLimId()!=null) {
				FncPreAbsLimVO limVo=this.fncPreAbsLimService.selectById(fncPrjBscInfoVO.getLimId());
				view.addObject("limVo", limVo);
			}
//			CapAdvRuleInfoQueryCondition qc=new CapPrjRuleRQueryCondition();
//			qc.setFncPrjId(Long.parseLong(id));
//			qc.setIsValid(1);
//			List<CapAdvRuleInfoDTO>  list =capAdvRuleInfoService.selectAdvRuleInfoByPrjId(qc);
//			if (list!=null && list.size()>0) {
//				CapAdvRuleInfoDTO rowdata=list.get(0);
//				view.addObject("rule", rowdata);
//			}
			List<KeyValueVO> payMayList=this.getKvList(FriBaseInfoConstant.FNC_PAY_MAY);//再融资支付渠道
			view.addObject("payMayList",payMayList);//再融资支付渠道
		}
		} catch (Exception e) {
			// TODO: handle exception
			BaseLogUtils.error(logger, "toDetailPage1", "查询数据失败,主键["+id+"]."+e.getMessage(), CurrentThreadContext.getCurrentUserName());
			
		}
		BaseLogUtils.info(logger, "toDetailPage1", "查询数据完成. DATA:" + JSONObject.toJSONString(id), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * By JL At 2017-11-27
	 * 到浏览页面-值展示项目基本信息(无其他页签)
	 */
	@RequestMapping(value = "/toDetailPage2.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toDetailPage2(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");

		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjBscInfoDetail2");
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id);  
			view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);
		}
		BaseLogUtils.info(logger, "toDetailPage2", "查询数据完成. DATA:" + JSONObject.toJSONString(id), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	@RequestMapping(value = "/tofstpyDetailPage.do", method = { RequestMethod.GET })
	public ModelAndView tofstpyDetailPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjFstpyInfoDetail");
		String fncPrjId = request.getParameter("fncPrjId");
		view.addObject("fncPrjId", fncPrjId);
		return view;
	}
	
	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/remove.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public DataResultVO remove(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "删除成功!");
		try {
			this.fncPrjBscInfoService.removeById(Long.parseLong(id));
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			result.setInfo("删除成功!");
			BaseLogUtils.info(logger, "remove", "删除数据,主键["+id+"].", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "remove", "删除数据失败,主键["+id+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误!");
			BaseLogUtils.error(logger, "remove", "删除数据失败,主键["+id+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	private List<KeyValueVO> getKvList(String grpCd){
		List<KeyValueVO> kvList = new ArrayList<>();
		try {
			List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), grpCd);
			if(CollectionUtils.isNotEmpty(sysDictionaryDTOList)){
				for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
					KeyValueVO keyValueVO = new KeyValueVO();
					keyValueVO.setKey(sysDictionaryDTO.getCode());
					keyValueVO.setValue(sysDictionaryDTO.getCodeNm());
					kvList.add(keyValueVO);
				}
			}
		} catch (BaseException e) {
			BaseLogUtils.info(logger, "getKvList", "获取字典项组"+grpCd+"失败.ERROR:"+e.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception e) {
			BaseLogUtils.error(logger, "getKvList", "获取字典项组"+grpCd+"失败,系统错误.ERROR:"+e.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return kvList;
	}
	
	
	
	/**
	 * 检查名称是否存在
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/checkprjNm.do", method = { RequestMethod.POST})
	@ResponseBody
	public Object checktmplNm(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String fncprjnm = request.getParameter("fncprjnm");//模板名称是否相同
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "获取成功");
		if(StringUtils.isEmpty(fncprjnm)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("参数不完整！");
			return result;
		}


			Pager page = new Pager();


			FncPrjBscInfoQueryCondition qc = new FncPrjBscInfoQueryCondition();
			qc.setFncprjnm(fncprjnm);;
			page.setCondition(qc);
	            
	
		try {
			//查询名称是否存在
		//	Pager pager = this.sysScoreTmplService.searchListPage(page);
		//	List<SysScoreTmplVO> list = (List<SysScoreTmplVO>) pager.getResultList();	
		//	if(CollectionUtils.isEmpty(list)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
		//		result.setInfo("数据不存在！");
		//	}
		//	result.setData(list);
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			logger.error(ex.getMessage(), ex);
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("获取数据失败！");
			logger.error("获取数据失败！", ex);
		}
		return result;
	}
	
	@RequestMapping(value = "/addFlowStart.do", method = { RequestMethod.POST})
	@ResponseBody
	public Object addFlowStart(HttpServletRequest request, HttpServletResponse response) {

		String id = request.getParameter("id");
		String procDefKey = request.getParameter("procDefKey");
		String procDefId = request.getParameter("procDefId");
		String procNo = request.getParameter("procNo");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "addFlowStart", SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY, CurrentThreadContext.getCurrentUserName());
			return result;
		}
		FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
		try {
			//流程定义Key和流程定义ID 如果是前端选择的则直接指定,如果不是则系统自动按照配置选择唯一一条记录,如果找不到会提示
			flowStartParamsDTO.setAudStsCd(""+FlowConstant.FLOW_CHECK_STATE_IN);

			flowStartParamsDTO.setProcDefKey(procDefKey);
			flowStartParamsDTO.setProcDefId(procDefId);
			flowStartParamsDTO.setProcNo(procNo);
			flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			flowStartParamsDTO.setBusinessKey(id);
			flowStartParamsDTO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			flowStartParamsDTO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
			flowStartParamsDTO.setSysCd(CurrentThreadContext.getCurrentSysCd());
			flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
			flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
			
			flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);//优先级,可以在界面定义
			///////////////////////////////////////////////////////////
			flowStartParamsDTO.setWordsInTheTable(FncPrjBaseInfoConstant.REF_FLOW_S_H_FPI);
			flowStartParamsDTO.setBusinessType(FncPrjBaseInfoConstant.FLOW_BUSINESS_TYP_FNC_PRJ_BSC_INFO);//确认用不用
			int fncprjst=FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_ST_CD_EXAM_ING;
			int transt=0;
			if(procDefKey.indexOf("R005")!=-1){
				flowStartParamsDTO.setModelTyp("R005");//需要和流程配置中的模块类型匹配-提款	
				fncprjst=6;
				transt=1;
			}
			if(procDefKey.indexOf("R004")!=-1){
				flowStartParamsDTO.setModelTyp("R004");//需要和流程配置中的模块类型匹配-立项	
				fncprjst=FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_ST_CD_EXAM_ING;
				//发起项目审核流程，授信状态改为授信中，报价方案改为流程中
				//id根据项目主键id获取项目信息
				FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));
				if(fncPrjBscInfoVO.getCrId()!=null){//授信信息
					CrBaseInfoVO	crBaseInfoVO = this.crBaseInfoService.selectByCrId(fncPrjBscInfoVO.getCrId());
					if(crBaseInfoVO.getCrSt()!=null && !"".equals(crBaseInfoVO.getCrSt().toString())){
						if(!"1".equals(crBaseInfoVO.getCrSt().toString())){
							CrBaseInfoVO crBaseDao=new CrBaseInfoVO();
							crBaseDao.setEdDt(crBaseInfoVO.getEdDt());
							crBaseDao.setId(crBaseInfoVO.getId());
							//修改授信状态为授信中
							crBaseDao.setCrSt(CrBaseInfoConstant.CR_BSC_INFO_CR_ST_CRING);
							this.crBaseInfoService.modify(crBaseDao);
						}
					}
				}
				if(fncPrjBscInfoVO.getFncscmid()!=null){//方案信息fncscmid
					ScmBaseInfoVO scmBaseInfo= scmBaseInfoService.selectById(fncPrjBscInfoVO.getFncscmid());	
					if(scmBaseInfo.getScmSt()!=null && !"".equals(scmBaseInfo.getScmSt().toString())){
						if(!"3".equals(scmBaseInfo.getScmSt().toString())){
							ScmBaseInfoVO scmDao=new ScmBaseInfoVO();
							scmDao.setScmSt(ScmSt.CHECKING.getKey());//修改报价方案审核中
							scmDao.setFncScmId(fncPrjBscInfoVO.getFncscmid());
							scmBaseInfoService.modify(scmDao);
						}
					}
				}
				
			}					
            ///////////////////////////////////////////////////////////////////////////
			flowStartParamsDTO.setSearchDesc(CurrentThreadContext.getCurrentOrgDispNm()+"、授信流程大字段参数未定!");
			DataResultDTO dataResultDTO = this.fncPrjBscInfoService.addFlowStart(flowStartParamsDTO);
			if(!dataResultDTO.getCode().equals(BaseExceptionConstant.BASE_EXCEPTION_CODE_200)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_OPERATE_FAIL);
			}
			if(null!=dataResultDTO && null!=dataResultDTO.getData()){
				FlowStartedDTO flowStartedDTO = (FlowStartedDTO) dataResultDTO.getData();
				if(StringUtils.isNotBlank(flowStartedDTO.getNextOperUsrNames())){
	                result.setInfo("下一个节点操作人:"+flowStartedDTO.getNextOperUsrNames());
	            	//FncPrjBscInfoVO vo = new FncPrjBscInfoVO();
	            	//vo.setId(Long.parseLong(id));
	            	//vo.setFncprjstcd(2);
					//this.fncPrjBscInfoService.modify(vo);
	            }else{
	                result.setInfo("流程发起成功");
	            }
				FncPrjBscInfoVO succvo= new FncPrjBscInfoVO();
				succvo.setId(Long.parseLong(id));
				succvo.setFncprjstcd(fncprjst);
				succvo.setTransst(transt);
				this.fncPrjBscInfoService.modify(succvo);
			}
			

			/*if(null != dataResultDTO.getInfo() && StringUtils.isNotEmpty(dataResultDTO.getInfo())){
				StringBuffer info = new StringBuffer();
				info.append(result.getInfo());
				info.append(SysLogConstant.LOG_FLOW_NEXT_TASK_OPERATOR);
				info.append(dataResultDTO.getInfo());//操作人
				result.setInfo(info.toString());
			}*/
		} catch (BaseException e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
			BaseLogUtils.info(logger, "addFlowStart", "错误[BaseException],请求参数：" + JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
			e.getStackTrace();
		} catch (Exception e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "addFlowStart", "错误[Exception],请求参数：" + JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
			e.getStackTrace();
		}
		BaseLogUtils.info(logger, "addFlowStart", "查询数据完成. DATA:" + JSONObject.toJSONString(id), CurrentThreadContext.getCurrentUserName());
		return result;
	}
	
	/**
	 * 设置产品基本信息中关于字典项信息
	 * @param listVO
	 */
	private void setListVOWithDicInfo(List<FncPrjBscInfoVO> listVO) {
		String sysCd=CurrentThreadContext.getCurrentSysCd();
		String orgCd="0000";
		//CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd()
		Map<String, String> countrylist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_CTY);
		Map<String, String> bustypelist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_BUS_TYPE);
		Map<String, String> firtypelist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FriBaseInfoConstant.FUND_RAS_INS_BASE_INFO_INS_TYPE_CD);		
		Map<String, String> crsbjlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,CrBaseInfoConstant.CR_BSC_INFO_CR_SBJ);		
		Map<String, String> stcdlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_ST_CD);		
		Map<String, String> transstlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_TRANS_ST_CD);		
		Map<String, String> astIdlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_AST_ID);		
		if(CollectionUtils.isEmpty(listVO))return;
	//	Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd, DictionaryConstant.CODE_AUD_STS_CD);

		for (FncPrjBscInfoVO vo : listVO) {
			//金额
			
			//状态
			//System.out.println(stcdlist.get(vo.getFncprjstcd()+"")+""+stcdlist.containsKey(vo.getFncprjstcd()+""));
			if(stcdlist.containsKey(vo.getFncprjstcd()+"")){
				vo.setFncprjstNM(stcdlist.get(vo.getFncprjstcd()+""));
			}
			//到账状态
			if(transstlist.containsKey(vo.getTransst()+"")){
				vo.setTransstNM(transstlist.get(vo.getTransst()+""));
			}
			if(countrylist.containsKey(vo.getCountry()+"")){
				vo.setCountryNM(countrylist.get(vo.getCountry()+""));
			}
			if(bustypelist.containsKey(vo.getBustype()+"")){
				vo.setBustypeNM(bustypelist.get(vo.getBustype()+""));
			}
			if(firtypelist.containsKey(vo.getInstypecd()+"")){
				vo.setInstypeNM(firtypelist.get(vo.getInstypecd()+""));
			
			}
			if(crsbjlist.containsKey(vo.getCrsbj()+"")){
				vo.setCrsbjNM(crsbjlist.get(vo.getCrsbj()+""));
			}
			if(vo.getFstpyamt()==null){
				vo.setFstpyamt(0L);
			}
			if(vo.getFstpydepadd()!=null){
				vo.setFstpyamtall(vo.getFstpyamt()+Long.parseLong(vo.getFstpydepadd()));
			}else{
				vo.setFstpyamtall(vo.getFstpyamt());
			}
			//资产占用种类
			if(astIdlist.containsKey(vo.getAstId())){
				vo.setAstNm(astIdlist.get(vo.getAstId()));
			}
		}
	}
	
	/**
	 * 设置产品基本信息中关于字典项信息
	 * @param VO
	 */
	private void setVOWithDicInfo(FncPrjBscInfoVO vo) {
		String sysCd=CurrentThreadContext.getCurrentSysCd();
		String orgCd="0000";
		//CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd()

	//	Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd, DictionaryConstant.CODE_AUD_STS_CD);
		Map<String, String> countrylist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_CTY);
		Map<String, String> bustypelist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_BUS_TYPE);
		Map<String, String> firtypelist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FriBaseInfoConstant.FUND_RAS_INS_BASE_INFO_INS_TYPE_CD);		
		Map<String, String> crsbjlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,CrBaseInfoConstant.CR_BSC_INFO_CR_SBJ);		
		Map<String, String> stcdlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_ST_CD);		
		Map<String, String> transstlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_TRANS_ST_CD);	
		Map<String, String> astIdlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_AST_ID);		
		Map<String, String> isOutlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,AssPackInfoConstant.ASS_PACK_INFO_IS_MORTGAGE);//是否出表		
		SysBkAccInfoQueryCondition qc = new SysBkAccInfoQueryCondition();
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		List<SysBkAccInfoVO> bkAccList = sysBkAccInfoService.searchList(qc);
	 //   vo.setTranstm(DateUtils.parseDate(vo.getTranstm(), "yyyy-MM-dd"));
		//到账收款账户
		if(vo.getTransacc()!=null){
	for (SysBkAccInfoVO sysBkAccInfoVO : bkAccList) {
		if(sysBkAccInfoVO.getId().toString().equals(vo.getTransacc())){
			vo.setTransaccNm(sysBkAccInfoVO.getAccNo());
			break;
		}
	}	
		}
		
		//预放款收款账户
		if(vo.getExpwdacc()!=null){
	for (SysBkAccInfoVO sysBkAccInfoVO : bkAccList) {
		if(sysBkAccInfoVO.getId().toString().equals(vo.getExpwdacc())){
			vo.setExpwdaccNM(sysBkAccInfoVO.getAccNo());
			break;
		}
	}	
		}

			//审核状态
	
		if(stcdlist.containsKey(vo.getFncprjstcd()+"")){
			vo.setFncprjstNM(stcdlist.get(vo.getFncprjstcd()+""));
		}
		
		//到账状态
		if(transstlist.containsKey(vo.getTransst()+"")){
			vo.setTransstNM(transstlist.get(vo.getTransst()+""));
		}
		//国家
			if(countrylist.containsKey(vo.getCountry()+"")){
				vo.setCountryNM(countrylist.get(vo.getCountry()+""));
			}
			//业务类型
			if(bustypelist.containsKey(vo.getBustype()+"")){
				vo.setBustypeNM(bustypelist.get(vo.getBustype()+""));
			}
			//融资机构类型
			if(firtypelist.containsKey(vo.getInstypecd()+"")){
				vo.setInstypeNM(firtypelist.get(vo.getInstypecd()+""));
			}
			//资产占用种类
			if(astIdlist.containsKey(vo.getAstId())){
				vo.setAstNm(astIdlist.get(vo.getAstId()));
			}
			
			//授信主体
			if(crsbjlist.containsKey(vo.getCrsbj()+"")){
				vo.setCrsbjNM(crsbjlist.get(vo.getCrsbj()+""));
			}
			//首付款
			if(vo.getFstpyamt()==null){
				vo.setFstpyamt(0L);
			}
			if(vo.getFstpydepadd()!=null){
				vo.setFstpyamtall(vo.getFstpyamt()+Long.parseLong(vo.getFstpydepadd()));
			}else{
				vo.setFstpyamtall(vo.getFstpyamt());
			}
			//是否出表
			if(vo.getIsOut()!=null){
				if(isOutlist.containsKey(vo.getIsOut()+"")){
					vo.setIsOutNm(isOutlist.get(vo.getIsOut())+"");;
				}
			}
			//合同审核是否需要（1:需要 0:不需要）
			if(StringUtils.isNotBlank(vo.getContractAudit())) {
				if("1".equals(vo.getContractAudit())) {
					vo.setContractAuditNm("需要");
				}else {
					vo.setContractAuditNm("不需要");
				}
			}
	}
	////////////////////////////////////项目资产包///////////////////////////////////////////////////////////
	/**
	 * 跳转到资产包列表页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toAssPackInfoPage.do", method = {RequestMethod.GET})
	public ModelAndView toAssPackInfoPage(HttpServletRequest request, HttpServletResponse response){
		////logger.info("加载融资筛选列表页面.");
		String prjid = request.getParameter("prjid");
		
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjAssPackInfoListView");
		//获取融资基数数据字典信息
		List<KeyValueVO> fncCrdnltList = this.assPackInfoService.getKvList(AssPackInfoConstant.ASS_PACK_INFO_FNC_CRDNLT);
		view.addObject("fncCrdnltList", fncCrdnltList);
		//获取客户类型数据字典信息
		List<KeyValueVO> cstTypCdList = this.assPackInfoService.getKvList(AssPackInfoConstant.ASS_PACK_INFO_CST_TYPE_CD);
		view.addObject("cstTypCdList", cstTypCdList);
		//获取所属事业部数据字典信息
		List<KeyValueVO> buOrgCdList = this.assPackInfoService.getCodeDescList(AssPackInfoConstant.ASS_PACK_INFO_BU_ORG_CD);
		view.addObject("buOrgCdList", buOrgCdList);
		//是／否
		List<KeyValueVO> isMortgageList = this.assPackInfoService.getKvList(AssPackInfoConstant.ASS_PACK_INFO_IS_MORTGAGE);
		view.addObject("isMortgageList", isMortgageList);
		view.addObject("prjid",prjid);
		BaseLogUtils.info(logger, "toAssPackInfoPage", "查询数据完成. DATA:" + JSONObject.toJSONString(prjid), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	/**
	 * 导入资产包
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/inportAssPack.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object inportAssPack(HttpServletRequest request, HttpServletResponse response) throws Exception{
		String id = request.getParameter("id");
		String prjid = request.getParameter("prjid");
		
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "导入生成成功!");
		try {
			FncPrjBscInfoVO fpbivo= new FncPrjBscInfoVO();
			
			FncPrjBscInfoQueryCondition fpbiqc= new FncPrjBscInfoQueryCondition();
			fpbiqc.setAsspackid(Long.parseLong(id));

             
			
			//List<FncPrjBscInfoVO> fpbivos=this.fncPrjBscInfoService.searchList(fpbiqc);
			int flag=1;
			
			
	//		if (fpbivos!=null && fpbivos.size()==1 && fpbivos.get(0).getId()!=Long.parseLong(prjid)){
			
			AssPackInfoDTO	assvo = this.assPackInfoApiService.selectById(Long.valueOf(id), CurrentThreadContext.getCurrentSysCd(),
						CurrentThreadContext.getCurrentOrgCd());
			//assvo.setFncPrjId(prjid);
			FncPrjBscInfoVO fpivo=this.fncPrjBscInfoService.selectById(Long.parseLong(prjid));
			ScmBaseInfoVO scmvo=this.scmBaseInfoService.selectById(fpivo.getFncscmid());
			assvo.setFncCrdnlt(scmvo.getFncCrdnlt());
			assvo.setStdt(scmvo.getStdt());
			assvo.setEddt(scmvo.getEddt());
			//更新项目
			FncPrjBscInfoVO fpivo1=new FncPrjBscInfoVO();
			fpivo1.setId(Long.parseLong(prjid));
			fpivo1.setAsspackid(assvo.getId());
		    this.fncPrjBscInfoService.modify(fpivo1);			
			//更改资产包为未预约
			assvo.setIsYl(0);
			this.assPackInfoApiService.modify(assvo);
			//剔除占用的支付表
				List<FncPrjPayRltvInfoDTO> list=this.assPackInfoApiService.selectIsZyByAssPackId(assvo.getId());
				if (list!=null&&list.size()>0) {
					for (FncPrjPayRltvInfoDTO dto:list) {
						this.assPackInfoApiService.deletePayRltvInfo(dto);
					}
					
				}
		   //处理中间表FncPrjPayIns数据
			if (fpivo.getFncprjstcd()>=7&&fpivo.getFncprjstcd()<=12){
			   //先根据项目id删除数据
				FncPrjPayInsDTO t=new FncPrjPayInsDTO();
				t.setIsDel(1L);
				t.setFncPrjId(Long.parseLong(prjid));
				this.fncPrjPayInsApiService.updateByPrj(t);
			   //然后再添加数据
				this.fncPrjPayInsApiService.addByPrj(Long.parseLong(prjid));
			}
			//String name= assvo.getAssPackNm();
			//SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
			//System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
			//  name=name.split("@")[0]+"@"+df.format(new Date());
			//  assvo.setAssPackNm(name);
			//2020-1-6 lxb 去除复制资产包  
			//Long packId=this.fncPrjBscInfoService.copyPack(assvo);
//			List<FncPrjPayRltvInfoVO> fpprvos = this.assPackInfoService.selectByAssPackId(Long.valueOf(id));
//			for (FncPrjPayRltvInfoVO fncPrjPayRltvInfoVO : fpprvos) {
//				fncPrjPayRltvInfoVO.setAssPackId(packId);
//				//this.fncPrjBscInfoService.copyPayRltvInfo(fncPrjPayRltvInfoVO);
//			}
//			this.assPackInfoApiService.batchInsert(FncPrjPayRltvInfoVOTransform.toDTOList(fpprvos));
//			List<FncPrjPayRltvInfo2DTO> oldPaySchCds=this.assPackInfoApiService.selectOldByAssPackId(Long.valueOf(id));
//			//旧支付表保存
//			if (oldPaySchCds!=null) {
//				for (int i = 0; i < oldPaySchCds.size(); i++) {
//					FncPrjPayRltvInfo2DTO dto=oldPaySchCds.get(i);
//					dto.setAssPackId(packId);
//					long rid = this.assPackInfoApiService.addPayRltvInfo2(dto);				
//					
//				}
//			}
			
		//	}else if (fpbivos==null || fpbivos.size()==0){
		//		FncPrjBscInfoVO fpivo= new FncPrjBscInfoVO();
		//		fpivo.setId(Long.parseLong(prjid));
		//		fpivo.setAsspackid(Long.parseLong(id));
		//		this.fncPrjBscInfoService.modify(fpivo);	
		//	}
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			result.setInfo("导入生成成功!");
			BaseLogUtils.info(logger, "remove", "导入生成数据,主键["+id+"].", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "remove", "导入生成数据失败,主键["+id+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误!");
			BaseLogUtils.error(logger, "remove", "导入生成数据失败,主键["+id+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		BaseLogUtils.info(logger, "inportAssPack", "查询数据完成. DATA:id" + JSONObject.toJSONString(id)+"prjid:"+JSONObject.toJSONString(prjid), CurrentThreadContext.getCurrentUserName());
		return result;
	}
	/**
	 * 到资产包信息页面
	 */
	@RequestMapping(value = "/viewAssPackInfoDetail.do", method = { RequestMethod.GET})
	public ModelAndView viewAssPackInfoDetail(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		String prjid = request.getParameter("prjid");
		String flag = request.getParameter("flag");
		CrBaseInfoVO cbvo=new CrBaseInfoVO();
		cbvo.setCrBal(new BigDecimal(0.00));
		FncPrjBscInfoVO fpivo= this.fncPrjBscInfoService.selectById(Long.parseLong(prjid));
		if(StringUtils.isNotEmpty(fpivo.getCrId())){
			 cbvo=this.crBaseInfoService.selectByCrId(fpivo.getCrId());
		}
		
		if(flag==null || flag.equals("")){
			flag="1";
		}
		if(id==null || id.equals("")){
		FncPrjBscInfoVO vo=this.fncPrjBscInfoService.selectById(Long.parseLong(prjid));
			if(vo!=null && vo.getAsspackid()!=null){
				id=vo.getAsspackid()+"";
			}
		}
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjAssPackInfoListDetail");
		view.addObject("id", id);
		view.addObject("prjid", prjid);
		view.addObject("flag", flag);
//		//获取融资基数数据字典信息
//		List<KeyValueVO> fncCrdnltList = this.assPackInfoService.getKvList(AssPackInfoConstant.ASS_PACK_INFO_FNC_CRDNLT);
//		view.addObject("fncCrdnltList", fncCrdnltList);
//		//获取客户类型数据字典信息
//		List<KeyValueVO> cstTypCdList = this.assPackInfoService.getKvList(AssPackInfoConstant.ASS_PACK_INFO_CST_TYPE_CD);
//		view.addObject("cstTypCdList", cstTypCdList);
//		//获取所属事业部数据字典信息
//		List<KeyValueVO> buOrgCdList = this.assPackInfoService.getCodeDescList(AssPackInfoConstant.ASS_PACK_INFO_BU_ORG_CD);
//		view.addObject("buOrgCdList", buOrgCdList);
//		//是／否
//		List<KeyValueVO> isMortgageList = this.assPackInfoService.getKvList(AssPackInfoConstant.ASS_PACK_INFO_IS_MORTGAGE);
//		view.addObject("isMortgageList", isMortgageList);
		view.addObject("cbvo",cbvo);
		BaseLogUtils.info(logger, "viewAssPackInfoDetail", "查询数据完成. DATA:id" + JSONObject.toJSONString(id)+"prjid:"+JSONObject.toJSONString(prjid), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	////////////////////////////////////项目预提款///////////////////////////////////////////////////////////
	/**
	 * 到预放款页面
	 */
	@RequestMapping(value = "/toWithholdAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toWithholdingAddPage(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");
		String pflag  = request.getParameter("pflag");
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjWithholdAdd");
		view.addObject("pflag", pflag);
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id);  
				view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);
			//add  by gengchunlan 20180427
			if(fncPrjBscInfoVO.getCrId()!=null){//授信信息
				CrBaseInfoVO	crBaseInfoVO = this.crBaseInfoService.selectByCrId(fncPrjBscInfoVO.getCrId());
				Map<String, String> crstMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CrBaseInfoConstant.CR_BSC_INFO_CR_ST);
				if(crBaseInfoVO.getCrSt()!=null){//处理授信状态
					if(crstMap.containsKey(crBaseInfoVO.getCrSt().toString())){
						crBaseInfoVO.setCrStNm(crstMap.get(crBaseInfoVO.getCrSt().toString()));
					}
				}
				view.addObject("crBaseInfo", crBaseInfoVO);
			}
			if(fncPrjBscInfoVO.getFncscmid()!=null){//方案信息fncscmid
				ScmBaseInfoVO scmBaseInfo= scmBaseInfoService.selectById(fncPrjBscInfoVO.getFncscmid());	
				Map<String, String> scmMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), ScmInfoConstant.FNC_SCM_BSC_INFO_SCM_ST);
				if(scmBaseInfo.getScmSt()!=null){//方案状态
					if(scmMap.containsKey(scmBaseInfo.getScmSt().toString())){
						scmBaseInfo.setScmDes(scmMap.get(scmBaseInfo.getScmSt().toString()));
					}
				}
				view.addObject("scmBaseInfo", scmBaseInfo);
			}//end  by gengchunlan 20180427
			List<KeyValueVO> payMayList=this.getKvList(FriBaseInfoConstant.FNC_PAY_MAY);//再融资支付渠道
			view.addObject("payMayList",payMayList);//再融资支付渠道
		}
		BaseLogUtils.info(logger, "toWithholdingAddPage", "查询数据完成. DATA:id" + JSONObject.toJSONString(id), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	
	////////////////////////////////////项目到账提款///////////////////////////////////////////////////////////
	/**
	 * 到到账提款列表页面
	 */
	@RequestMapping(value = "/toTransferListPage.do", method = { RequestMethod.GET})
	public ModelAndView toTransferListPage(HttpServletRequest request, HttpServletResponse response) {
		List<FriBaseInfoVO>  friList = null;
		List<KeyValueVO> transstlist =null;
		try {
			FriBaseInfoQueryCondition friqc = new FriBaseInfoQueryCondition();
			friqc.setInsUseCd("1");
			friList=friBaseInfoService.searchList(friqc);
			//add 到账状态  by gengchunlan  20180222
			transstlist = this.getKvList(FncPrjBaseInfoConstant.FNC_PRJ_TRANS_ST_CD);
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toListPage", "异常"+e.getMessage(), e);
		}
		////logger.info("加载crbaseinfo列表页面.");
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncprjTransferList");
		view.addObject("frilist",JSON.toJSONString(friList));
		view.addObject("transstlist", transstlist);//add 到账状态List by gengchunlan 2018022
		return view;
	}
	/**
	 * 到项目确认到账页面
	 */
	@RequestMapping(value = "/toTransferAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toTransferAddPage(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");
		String chflag  = request.getParameter("chflag");
		if(null==chflag || chflag.equals("")){
			chflag="0";
		}
		String currentTabid=request.getParameter("currentTabid");
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjTransferInfoAdd");
		BaseLogUtils.info(logger, "toTransferAddPage", "进入确认到账页面:/rfbuss/fncprjbscinfo/fncPrjTransferInfoAdd.jsp", CurrentThreadContext.getCurrentUserName());
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id);  
			view.addObject("chflag", chflag);
			view.addObject("currentTabid", currentTabid); 
			view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);
		}
		return view;
	}
	/**
	 * 到项目确认到账页面
	 */
	@RequestMapping(value = "/toTransferDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toTransferDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");

		String currentTabid=request.getParameter("currentTabid");
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjTransferInfoDetail");
		BaseLogUtils.info(logger, "toTransferAddPage", "进入确认到账页面:/rfbuss/fncprjbscinfo/fncPrjTransferInfoDetail.jsp", CurrentThreadContext.getCurrentUserName());
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id);  
			view.addObject("currentTabid", currentTabid); 
			view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);
		}
		return view;
	}	
	/**
	 * 得到一条记录
	 */
	@RequestMapping(value = "/getPrjfstpyById.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String fncPrjId = request.getParameter("fncPrjId");
		//DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "获取成功!");
		FncPrjDetailVO fncPrjDetailVO = null;
	//	try {
			fncPrjDetailVO = this.fncPrjFstpyInfoService.selectByFncPrjId(Long.valueOf(fncPrjId));
			// 设置数据字典项
			String sysCd = CurrentThreadContext.getCurrentSysCd();
			String orgCd = CurrentThreadContext.getCurrentOrgCd();
			Map<String, String> fncCrdnltCdMap = sysDictionaryApiService.searchGroupToMap(sysCd, orgCd, ScmInfoConstant.FNC_SCM_BSC_INFO_FNC_CRDNLT);// 融资基数
			if (null != fncPrjDetailVO.getFncCrdnlt()) {
				fncPrjDetailVO.setFncCrdnltNm(fncCrdnltCdMap.get(fncPrjDetailVO.getFncCrdnlt().toString()));
			}
			
			FncPrjFstpyInfoQueryCondition qc = new FncPrjFstpyInfoQueryCondition();
			qc.setFncPrjId(fncPrjId);
			List<FncPrjFstpyInfoVO> fncPrjFstpyInfoVOs = this.fncPrjFstpyInfoService.searchList(qc);
			// 保证金计入首付款
//			if (fncPrjDetailVO.getMrgnWthrInPay() == 1) {
//				qc.setScmChrgId("0"); // 保证金
//				FncPrjFstpyInfoVO mrgnFstpyInfoVO = this.fncPrjFstpyInfoService.selectByScmChrgId(qc);
//				if (null == mrgnFstpyInfoVO) {
//					mrgnFstpyInfoVO = new FncPrjFstpyInfoVO();
//				}
//				mrgnFstpyInfoVO.setScmChrgId("0");
//				mrgnFstpyInfoVO.setCostNm("保证金");
//				mrgnFstpyInfoVO.setCostPct(fncPrjDetailVO.getMrgnPct());
//				fncPrjFstpyInfoVOs.add(0, mrgnFstpyInfoVO);
//			}
//			fncPrjDetailVO.setFncPrjFstpyInfoVOs(fncPrjFstpyInfoVOs);
			
			// 保证金收款帐户信息
//			if (StringUtils.isNotEmpty(fncPrjDetailVO.getFstpyAccno())) {
//				BankAccInfoDTO bankAccInfoDTO = bankAccInfoApiService.selectById(Long.valueOf(fncPrjDetailVO.getFstpyAccno()), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
//				fncPrjDetailVO.setBaccInfoVO(BankAccInfoVOTransform.toVO(bankAccInfoDTO));
//			}
			
			// TODO 我司付款帐户信息
			ListPageVO<FncPrjFstpyInfoVO> listPage = new ListPageVO<FncPrjFstpyInfoVO>(fncPrjFstpyInfoVOs,1);
			
			//result.setData(fncPrjFstpyInfoVOs);
//		} catch (BaseException ex) {
//			result.setSuccess(BaseConstant.IS_YESNO_NO);
//			result.setInfo(ex.getMessage());
//			BaseLogUtils.info(logger, "getById", "获取数据失败,主键[" + fncPrjId + "]." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
//		} catch (Exception ex) {
//			result.setSuccess(BaseConstant.IS_YESNO_NO);
//			result.setInfo("系统错误!");
//			BaseLogUtils.error(logger, "getById", "获取数据失败,主键[" + fncPrjId + "]." + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
//		}
			BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(fncPrjFstpyInfoVOs), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	
	/**
	 * 到项目还款计划录入页面
	 */
	@RequestMapping(value = "/topayplanAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView topayplanAddPage(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");
		String chflag  = request.getParameter("chflag");
		String currentTabid=request.getParameter("currentTabid");
		if(null==chflag || chflag.equals("")){
			chflag="0";
		}
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjpayplanAdd");
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id); 
			view.addObject("chflag", chflag);
			view.addObject("currentTabid", currentTabid);
			view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);

			// 还本方式(数据字典)
			request.setAttribute("repayTypeList",
					sysDictionaryApiService.getKvList(FncPrjBaseInfoConstant.FNC_REPAY_TYPE,
							CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd()));
	
		}
		return view;
	}
	/**
	 * 到项目还款计划录入页面
	 */
	@RequestMapping(value = "/topayplanDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView topayplanDetailPage(HttpServletRequest request, HttpServletResponse response) {
		String id  = request.getParameter("id");
		String chflag  = request.getParameter("chflag");
		if(null==chflag || chflag.equals("")){
			chflag="0";
		}
		ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/fncPrjpayplanDetail");
		if(StringUtils.isNotEmpty(id)){
			FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));	
			this.setVOWithDicInfo(fncPrjBscInfoVO);
			view.addObject("id", id); 
			view.addObject("chflag", chflag);
			view.addObject("fncPrjBscInfo", fncPrjBscInfoVO);
		}
		return view;
	}
	
	/**
	 * 新增
	 */
	@RequestMapping(value = "/payplanadd.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object payplanadd(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		String payplanlist = request.getParameter("payplanlist");//付款计划明细
		String fllist = request.getParameter("fllist");//融资端明细
		String payplanpd = request.getParameter("payplanpd");
		String payplanli = request.getParameter("payplanli");
		String acXirr =request.getParameter("acXirr");
		String scmIntrtReal =request.getParameter("scmIntrtReal");
		String dura =request.getParameter("dura");
		String repayType =request.getParameter("repayType");//还本方式
		
		FncPrjBscInfoVO fpbvo=new FncPrjBscInfoVO();
		fpbvo.setId(Long.parseLong(id));
		if (StringUtils.isNotEmpty(payplanpd)) {
			fpbvo.setPayplanpd(payplanpd);
				
			}
		if (StringUtils.isNotEmpty(payplanli)) {
			fpbvo.setPayplanli(payplanli);
				
			}
		if (StringUtils.isNotEmpty(acXirr)) {
			fpbvo.setAcXirr(Double.parseDouble(acXirr)/100);
				
			}
		if (StringUtils.isNotEmpty(scmIntrtReal)) {
			fpbvo.setScmIntrtReal(new BigDecimal(scmIntrtReal).divide(new BigDecimal(100)));
				
			}
		if (StringUtils.isNotEmpty(dura)) {
			fpbvo.setDura(Double.parseDouble(dura));
				
			}
		if (StringUtils.isNotEmpty(repayType)) {
			fpbvo.setRepayType(repayType);
		}
		//fpbvo.setFncprjstcd(FncPrjBaseInfoConstant.FNC_PRJ_BSC_INFO_ST_CD_PAYING);
		this.fncPrjBscInfoService.modify(fpbvo);
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		
		
		List<FncPrjPayPlanVO> list = new ArrayList<FncPrjPayPlanVO>();
		if (StringUtils.isNotBlank(payplanlist)) {
			list = JSON.parseArray(payplanlist, FncPrjPayPlanVO.class);
			
		}
		List<FncPrjPayPlanVO> list2 = new ArrayList<FncPrjPayPlanVO>();
		if (StringUtils.isNotBlank(fllist)) {
			list2 = JSON.parseArray(fllist, FncPrjPayPlanVO.class);
			
		}

	try {
		FncPrjPaySchMVO paymvo=new FncPrjPaySchMVO();
	 	 this.fncPrjPayPlanService.removeById(Long.parseLong(id));
	    for (FncPrjPayPlanVO entity : list) {
	    	
	 	   entity.setProjId(Long.parseLong(id));
	 	   this.fncPrjPayPlanService.add(entity);
	       }
	    for (FncPrjPayPlanVO entity : list2) {
	    	
		 	   entity.setProjId(Long.parseLong(id));
		 	  
		 	   this.fncPrjPayPlanService.add(entity);
		    }
	    /////////////////////////////////////////////
	//    this.updatePay(list,list2,Long.parseLong(id));
	    ///////////////////////////////////////////////
		result.setSuccess(BaseConstant.IS_YESNO_YES);
		result.setData(id);
		
		BaseLogUtils.info(logger, "add", "新增数据 ", CurrentThreadContext.getCurrentUserName());
	} catch (BaseException ex) {
		result.setSuccess(BaseConstant.IS_YESNO_NO);
		result.setInfo(ex.getMessage());
		BaseLogUtils.info(logger, "add", "新增数据失败"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
	}catch (Exception ex) {
		result.setSuccess(BaseConstant.IS_YESNO_NO);
		result.setInfo("新增失败!");
		BaseLogUtils.error(logger, "add", "新增数据失败"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
	}
	
	return result;
	
	
	}
	
	/**
	 * 初始化列表
	 * @param request
	 * @param response
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initpayplanList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initpayplanList(HttpServletRequest request, HttpServletResponse response) {

	
	
		String id = request.getParameter("id");
	
		

		
		FncPrjPayPlanQueryCondition qc=new FncPrjPayPlanQueryCondition();
		
	
		if (StringUtils.isNotEmpty(id)) {
			qc.setProjId(Long.parseLong(id));
		}
		
		

		
		List<FncPrjPayPlanVO> list = this.fncPrjPayPlanService.searchList(qc);
		
		
		ListPageVO<FncPrjPayPlanVO> listPage = new ListPageVO<FncPrjPayPlanVO>(list, 1);
		



		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	/**
	 * 初始化列表
	 * @param request
	 * @param response
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initchgrList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initchgrList(HttpServletRequest request, HttpServletResponse response) {

	
	
		String id = request.getParameter("id");
	
		

		
	//	FncPrjPayPlanQueryCondition qc=new FncPrjPayPlanQueryCondition();
		
	
		//if (StringUtils.isNotEmpty(id)) {
		//	qc.setProjId(Long.parseLong(id));
		//}
		
		

		
		List<FncPrjPayPlanVO> list = this.fncPrjPayPlanService.selectchgr(Long.parseLong(id));
		
		
		ListPageVO<FncPrjPayPlanVO> listPage = new ListPageVO<FncPrjPayPlanVO>(list, 1);
		



		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	
	
	private Long updatePay(List<FncPrjPayPlanVO> list,List<FncPrjPayPlanVO> list2,Long prjid){
		FncPrjPaySchMVO mvo = new FncPrjPaySchMVO();
		FncPrjBscInfoVO fpvo=this.fncPrjBscInfoService.selectById(prjid);
		
		mvo.setProjId(prjid);
		mvo.setFundRasInsId(Long.parseLong(fpvo.getFncinsid()));

		Long payid=this.fncPrjPaySchService.add(mvo);
		if(null==payid){
			payid=mvo.getId();
		}
		//fncPrjPaySchService
		List<FncPrjPaySchDVO> dvoLst = new ArrayList<FncPrjPaySchDVO>();
		for(int i=0;i<list.size();i++){
			FncPrjPayPlanVO vo = list.get(i);
			
			if(vo.getCapital()!=null && vo.getCapital()>0 ){	
				FncPrjPaySchDVO dvo = new FncPrjPaySchDVO();
				dvo.setPaySchId(payid);
				dvo.setCrtTm(new Date());
				dvo.setPayPd(vo.getPdMun().intValue());
				dvo.setGthrDt(vo.getImputDate());
				dvo.setPayDt(vo.getRepayDate());
				dvo.setFeeClsCd(1);	
				dvo.setCanSt(1);
				dvo.setFeeAmt(new BigDecimal(vo.getCapital()));
				dvo.setArAmt(new BigDecimal(vo.getCapital()));
                dvo.setVersion(prjid);
				dvoLst.add(dvo);
			}
			
			if(vo.getInterest()!=null && vo.getInterest()>0  ){	
				
				FncPrjPaySchDVO dvo = new FncPrjPaySchDVO();
				dvo.setPaySchId(payid);
				dvo.setCrtTm(new Date());
				dvo.setPayPd(vo.getPdMun().intValue());
				dvo.setGthrDt(vo.getImputDate());
				dvo.setPayDt(vo.getRepayDate());
				dvo.setFeeClsCd(2);	
				dvo.setCanSt(1);
				dvo.setFeeAmt(new BigDecimal(vo.getInterest()));
				dvo.setArAmt(new BigDecimal(vo.getInterest()));
				dvo.setVersion(prjid);
				dvoLst.add(dvo);
				
			}
			
			if(vo.getOtherChar()!=null && vo.getOtherChar()>0  ){	
				FncPrjPaySchDVO dvo = new FncPrjPaySchDVO();
				dvo.setPaySchId(payid);
				dvo.setCrtTm(new Date());
				dvo.setPayPd(vo.getPdMun().intValue());
				dvo.setGthrDt(vo.getImputDate());
				dvo.setPayDt(vo.getRepayDate());
				dvo.setFeeClsCd(5);	
				dvo.setCanSt(1);
				dvo.setFeeAmt(new BigDecimal(vo.getOtherChar()));
				dvo.setArAmt(new BigDecimal(vo.getOtherChar()));
				dvo.setVersion(prjid);
				dvoLst.add(dvo);
			
			}
			
			if(vo.getOverColl()!=null && vo.getOverColl()>0  ){	
				FncPrjPaySchDVO dvo = new FncPrjPaySchDVO();
				dvo.setPaySchId(payid);
				dvo.setCrtTm(new Date());
				dvo.setPayPd(vo.getPdMun().intValue());
				dvo.setGthrDt(vo.getImputDate());
				dvo.setPayDt(vo.getRepayDate());
				dvo.setFeeClsCd(3);	
				dvo.setCanSt(1);
				dvo.setFeeAmt(new BigDecimal(vo.getOverColl()));
				dvo.setArAmt(new BigDecimal(vo.getOverColl()));
				dvo.setVersion(prjid);
				dvoLst.add(dvo);
				
			}
			
			
		}
		for(int i=0;i<list2.size();i++){
			FncPrjPayPlanVO vo = list.get(i);
			FncPrjPaySchDVO dvo = new FncPrjPaySchDVO();
			dvo.setPaySchId(payid);
			dvo.setCrtTm(new Date());
			dvo.setPayPd(vo.getPdMun().intValue());
			dvo.setGthrDt(vo.getImputDate());
			dvo.setPayDt(vo.getRepayDate());
			dvo.setFeeClsCd(4);	
			dvo.setCanSt(1);
			dvo.setFeeAmt(new BigDecimal(vo.getCapital()));
			dvo.setArAmt(new BigDecimal(vo.getCapital()));
			dvo.setVersion(prjid);
			dvoLst.add(dvo);
		}
		return this.fncPrjPaySchService.batchInsertDetail(dvoLst);
	}
	
	@RequestMapping(value = "/addpayplanFlowStart.do", method = { RequestMethod.POST})
	@ResponseBody
	public Object addpayplanFlowStart(HttpServletRequest request, HttpServletResponse response) {

		String id = request.getParameter("id");
		String procDefKey = request.getParameter("procDefKey");
		String procDefId = request.getParameter("procDefId");
		String procNo = request.getParameter("procNo");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "addFlowStart", SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY, CurrentThreadContext.getCurrentUserName());
			return result;
		}
		FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
		try {
			//流程定义Key和流程定义ID 如果是前端选择的则直接指定,如果不是则系统自动按照配置选择唯一一条记录,如果找不到会提示
			flowStartParamsDTO.setAudStsCd(""+FlowConstant.FLOW_CHECK_STATE_IN);

			flowStartParamsDTO.setProcDefKey(procDefKey);
			flowStartParamsDTO.setProcDefId(procDefId);
			flowStartParamsDTO.setProcNo(procNo);
			flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			flowStartParamsDTO.setBusinessKey(id);
			flowStartParamsDTO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			flowStartParamsDTO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
			flowStartParamsDTO.setSysCd(CurrentThreadContext.getCurrentSysCd());
			flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
			flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
			
			flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);//优先级,可以在界面定义
			///////////////////////////////////////////////////////////
			flowStartParamsDTO.setWordsInTheTable(FncPrjBaseInfoConstant.REF_FLOW_S_H_FPI);
			flowStartParamsDTO.setBusinessType(FncPrjBaseInfoConstant.FLOW_BUSINESS_TYP_FNC_PRJ_BSC_INFO);//确认用不用
			flowStartParamsDTO.setModelTyp(FncPrjBaseInfoConstant.FLOW_MODEL_TYP_FPP);//需要和流程配置中的模块类型匹配			
            ///////////////////////////////////////////////////////////////////////////
			flowStartParamsDTO.setSearchDesc(CurrentThreadContext.getCurrentOrgDispNm()+"、录入还款表大字段参数未定!");
			DataResultDTO dataResultDTO = this.fncPrjBscInfoService.addFlowStart(flowStartParamsDTO);
			if(!dataResultDTO.getCode().equals(BaseExceptionConstant.BASE_EXCEPTION_CODE_200)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_OPERATE_FAIL);
			}
			if(null!=dataResultDTO && null!=dataResultDTO.getData()){
				FlowStartedDTO flowStartedDTO = (FlowStartedDTO) dataResultDTO.getData();
				if(StringUtils.isNotBlank(flowStartedDTO.getNextOperUsrNames())){
	                result.setInfo("下一个节点操作人:"+flowStartedDTO.getNextOperUsrNames());
	            	FncPrjBscInfoVO vo = new FncPrjBscInfoVO();
	            	//vo.setId(Long.parseLong(id));
	            	//vo.setFncprjstcd(2);
					//this.fncPrjBscInfoService.modify(vo);
	            }else{
	                result.setInfo("流程发起成功");
	            }
				FncPrjBscInfoVO succvo= new FncPrjBscInfoVO();
				succvo.setId(Long.parseLong(id));
				succvo.setTransst(FncPrjBaseInfoConstant.FNC_PRJ_TRANS_ST_CD_INPORTING);
				this.fncPrjBscInfoService.modify(succvo);
			}
			

			/*if(null != dataResultDTO.getInfo() && StringUtils.isNotEmpty(dataResultDTO.getInfo())){
				StringBuffer info = new StringBuffer();
				info.append(result.getInfo());
				info.append(SysLogConstant.LOG_FLOW_NEXT_TASK_OPERATOR);
				info.append(dataResultDTO.getInfo());//操作人
				result.setInfo(info.toString());
			}*/
		} catch (BaseException e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
			BaseLogUtils.info(logger, "addFlowStart", "错误[BaseException],请求参数：" + JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
			e.getStackTrace();
		} catch (Exception e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "addFlowStart", "错误[Exception],请求参数：" + JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
			e.getStackTrace();
		}
		return result;
	}
	
	@RequestMapping(value = "/importExcel.do",method = { RequestMethod.POST, RequestMethod.GET})  
    @ResponseBody  
    public Object importExcel( @RequestParam(value = "upfile") MultipartFile upfile,HttpServletRequest request) throws IOException{  

		
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "导入成功");
		if (null == upfile) { 
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("模板文件为空,请选择文件");
			BaseLogUtils.info(logger, "addFlowStart", SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY, CurrentThreadContext.getCurrentUserName());
			return result; 
     
        }  
                  
//      String path = request.getSession().getServletContext().getRealPath("demo2");  
          
       // String path = "E:\\demo";  
        //容错处理  
       // File dir = new File(path);  
       // if(!dir.exists()) {  
       //     dir.mkdirs();  
       // }  
        String fileName = upfile.getOriginalFilename();//report.xls 
        String[] names=fileName.split("\\.");
        if(!names[names.length-1].toLowerCase().equals("xls") && !names[names.length-1].toLowerCase().equals("xlsx")){
        	result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("上传文件必须是 xls 或者 xlsx");
			BaseLogUtils.info(logger, "addFlowStart", SysLogConstant.LOG_CMM_ENABLE_FAIL, CurrentThreadContext.getCurrentUserName());
			return result; 
        }
        
        String fileName2 = upfile.getName();//excelFile  
          
        InputStream fis = upfile.getInputStream();  
         
        result = this.parseExcel(fis,result,Long.parseLong(id));  
           //解析到的数据就可以做一些数据库的插入操作了……  
       return result;  
    }  
	
	
	
		@RequestMapping(value = "/exportExcel.do", method = { RequestMethod.POST })
		@ResponseBody
		public Object exportExcel(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		

			DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "导出成功");
			String currentPage = request.getParameter("page");
			String pageSize = request.getParameter("pagesize");
			String id = request.getParameter("id");			//资产包id
			String fncCrdnlt = request.getParameter("fncCrdnlt");		//融资基数
			String stdt = request.getParameter("stdt");			//计划融资日期开始时间
			String eddt = request.getParameter("eddt");			//计划融资日期结束时间
			
			
			if(StringUtils.isEmpty(id)){
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,"资产包id不能为空!");
			}
			Pager page = new Pager();
			if (StringUtils.isNotEmpty(currentPage)) {
				page.setCurrentPage(Integer.parseInt(currentPage));
			}
			if (StringUtils.isNotEmpty(currentPage)) {
				page.setEveryPage(Integer.parseInt(pageSize));
			}
			
			AssPackInfoQueryCondition condition = new AssPackInfoQueryCondition();
			if (StringUtils.isNotEmpty(id)) {
				condition.setId(Long.valueOf(id.trim()));
				condition.setIsEdit(1);
			}
			if (StringUtils.isNotEmpty(fncCrdnlt)) {
				condition.setFncCrdnlt(Integer.parseInt(fncCrdnlt.trim()));
			}
			if (StringUtils.isNotEmpty(stdt)) {
				condition.setStdt(DateUtils.formatStringToDate(stdt.trim(), DateUtils.YYYY_MM_DD));
			}
			if (StringUtils.isNotEmpty(eddt)) {
				condition.setEddt(DateUtils.formatStringToDate(eddt.trim(), DateUtils.YYYY_MM_DD));
			}
			
			condition.setFinancingAmount(new BigDecimal(0));
			
			condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			page.setCondition(condition);
			
			Pager resultPager = this.assPackInfoService.searchPaySchInfoList(page);
			List<AssPackListDTO> dtoList = (List<AssPackListDTO>)resultPager.getResultList(); 
			List<FncPrjPayRltvInfo2DTO> oldList= this.assPackInfoService.selectOldByAssPackId(new Long(id));
			 
			    String[] excelHeader = { "支付表号","旧支付表号"};  
		        String[] ds_titles = { "paySchId","payCode"};  
		        int[] ds_format = {1,1};  
		        try{ 
		        	//  JSONArray jsonArray = JSON.parseArray(jsonArrayData);  
		        	  
		              List<Map<String,Object>> data = new ArrayList<Map<String,Object>>();  
		              if (dtoList!=null) {
			              for (AssPackListDTO dto : dtoList) {
							Map<String,Object> map= new HashMap<>();
							map.put("paySchId", dto.getPaySchId());
							data.add(map);
						  }
		              }
		              if (oldList!=null) {
		            	  for (int i = 0; i < oldList.size(); i++) {
							  if (data.size()>i) {
								  data.get(i).put("payCode", oldList.get(i).getPayCode());
							  }else {
								  Map<String,Object> map= new HashMap<>();
								  map.put("payCode", oldList.get(i).getPayCode());
								  data.add(map);
							  }	
		            		 
						  }
					 }
		              
		            this.export("资产包表-"+id, "资产", excelHeader, ds_titles, ds_format, null, data, request, response);  
		        }catch(Exception e){  
		            logger.error("导出文件异常", e);  
		        }  
	       return result;
    } 
		
		@RequestMapping(value = "/getXIRR.do", method = { RequestMethod.POST })
		@ResponseBody
		public Object getXIRR(HttpServletRequest request, HttpServletResponse response) throws Exception {
			DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "导出成功");
			String payplanlist = request.getParameter("payplanlist");//还款表明细
			String fllist=request.getParameter("fllist");//费用明细
			String acFiAmt=request.getParameter("acFiAmt");//实际融资金额
			String fstpyamt=request.getParameter("fstpyamt");//首付款金额
			String transtm=request.getParameter("transtm");
			String fncPrjId=request.getParameter("prjid");
			List<FncPrjPayPlanVO> flist1 = new ArrayList<FncPrjPayPlanVO>();
			if (StringUtils.isNotBlank(payplanlist)) {
				flist1 = JSON.parseArray(payplanlist, FncPrjPayPlanVO.class);
				
			}
			List<FncPrjPayPlanVO> flist2 = new ArrayList<FncPrjPayPlanVO>();
			if (StringUtils.isNotBlank(fllist)) {
				flist2 = JSON.parseArray(fllist, FncPrjPayPlanVO.class);
				
			}
			List<UpbaaDate> list1= new ArrayList<UpbaaDate>();//repayDate
			UpbaaDate ud0= new UpbaaDate(transtm, -1*(Double.parseDouble(acFiAmt)-Double.parseDouble(fstpyamt)));
			list1.add(ud0);
			Double overcoll=0.00;
			for (FncPrjPayPlanVO vo : flist1) {
				Double paynum=0.00;
				
				if(null!=vo.getRental() && vo.getRental()>0){
				//	paynum+=vo.getRental();
				}
				if(null!=vo.getCapital() && vo.getCapital()>0){
					paynum+=vo.getCapital();
				}
				if(null!=vo.getInterest() && vo.getInterest()>0){
					paynum+=vo.getInterest();
				}
				
				if(null!=vo.getOtherChar() && vo.getOtherChar()>0){
					paynum+=vo.getOtherChar();
				}
				if(null!=vo.getOverColl() && vo.getOverColl()>0){
					paynum+=vo.getOverColl();
					overcoll+=vo.getOverColl();
				}
				UpbaaDate ud= new UpbaaDate(DateUtils.formatDateToString(vo.getRepayDate(), DateUtils.YYYY_MM_DD), paynum);
				int j=0;
				for (int i = 0; i < list1.size(); i++) {
					UpbaaDate tud=list1.get(i);
					if(tud.getDaysFrom1970()<=ud.getDaysFrom1970()){
						j++;
					}else{
						break;
					}
				}
				list1.add(j,ud);
			}
			
			//获取保证金（计入首付）
			FncPrjFstpyInfoQueryCondition qc = new FncPrjFstpyInfoQueryCondition();
			qc.setFncPrjId(fncPrjId);
			double bond = fncPrjFstpyInfoService.getFncPrjFstpyBondAll(qc);
			
			for (FncPrjPayPlanVO vo : flist2) {
				if("0".equals(vo.getScmChegId())){
					if(vo.getCapital() != null) {
						bond= vo.getCapital()/100;
					}
				}
			}
			double bzj=bond+overcoll;//保证金+超额抵押
			List<UpbaaDate> list2= new ArrayList<UpbaaDate>();
			for (int i = list1.size()-1; i>=0; i--) {
				UpbaaDate ud=list1.get(i);
				
				if(bzj-ud.payment>=0 && ud.payment>0){
					bzj=bzj-ud.payment;	
				}else if(bzj-ud.payment<0 && ud.payment>0){
					
					ud.payment=ud.payment-bzj;
					bzj=0;
					list2.add(0, ud);
				}
	           if(ud.payment<0){
					list2.add(0, ud);
				}
			}
			
			Double rs=this.getXirr(list2);
			result.setData(rs);
			return result;
		}
		
		
		//计算久期
		@RequestMapping(value = "/getDURA.do", method = { RequestMethod.POST })
		@ResponseBody
		public Object getDURA(HttpServletRequest request, HttpServletResponse response) throws Exception {
			DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "导出成功");
			String payplanlist = request.getParameter("payplanlist");//付款计划明细
			String fllist=request.getParameter("fllist");//融资端明细
			String fstpyamt=request.getParameter("fstpyamt");
			String fncPrjId=request.getParameter("prjid");
			List<FncPrjPayPlanVO> flist1 = new ArrayList<FncPrjPayPlanVO>();
			if (StringUtils.isNotBlank(payplanlist)) {
				flist1 = JSON.parseArray(payplanlist, FncPrjPayPlanVO.class);
				
			}
			List<FncPrjPayPlanVO> flist2 = new ArrayList<FncPrjPayPlanVO>();
			if (StringUtils.isNotBlank(fllist)) {
				flist2 = JSON.parseArray(fllist, FncPrjPayPlanVO.class);
				
			}
			List<UpbaaDate> list1= new ArrayList<UpbaaDate>();//repayDate
			Double overcoll=0.00;
			for (FncPrjPayPlanVO vo : flist1) {
				Double paynum=0.00;
				
				if(null!=vo.getRental() && vo.getRental()>0){
				//	paynum+=vo.getRental();
				}
				if(null!=vo.getCapital() && vo.getCapital()>0){
					paynum+=vo.getCapital();
				}
				if(null!=vo.getInterest() && vo.getInterest()>0){
					paynum+=vo.getInterest();
				}
				
				if(null!=vo.getOtherChar() && vo.getOtherChar()>0){
					paynum+=vo.getOtherChar();
				}
				if(null!=vo.getOverColl() && vo.getOverColl()>0){
					paynum+=vo.getOverColl();
					overcoll+=vo.getOverColl();
				}
				UpbaaDate ud= new UpbaaDate(DateUtils.formatDateToString(vo.getRepayDate(), DateUtils.YYYY_MM_DD), paynum);
				int j=0;
				for (int i = 0; i < list1.size(); i++) {
					UpbaaDate tud=list1.get(i);
					if(tud.getDaysFrom1970()<=ud.getDaysFrom1970()){
						j++;
					}else{
						break;
					}
				}
				list1.add(j,ud);
			}
			//获取保证金（计入首付）
			FncPrjFstpyInfoQueryCondition qc = new FncPrjFstpyInfoQueryCondition();
			qc.setFncPrjId(fncPrjId);
			double bond = fncPrjFstpyInfoService.getFncPrjFstpyBondAll(qc);
			
			//获取保证金（费用明细）
			for (FncPrjPayPlanVO vo : flist2) {
				if("0".equals(vo.getScmChegId())){
					if(vo.getCapital() != null) {
						bond= vo.getCapital()/100;
					}
				}
			}
			
			double bzj=bond+overcoll;//保证金+超额抵押
			List<UpbaaDate> list2= new ArrayList<UpbaaDate>();
			for (int i = list1.size()-1; i>=0; i--) {
				UpbaaDate ud=list1.get(i);
				
				if(bzj-ud.payment>=0 && ud.payment>0){
					bzj=bzj-ud.payment;	
				}else if(bzj-ud.payment<0 && ud.payment>0){
					
					ud.payment=ud.payment-bzj;
					bzj=0;
					list2.add(0, ud);
				}
	           if(ud.payment<0){
					list2.add(0, ud);
				}
			}
			FncPrjBscInfoVO prjvo=this.fncPrjBscInfoService.selectById(Long.parseLong(fncPrjId));
			Long scmid=prjvo.getFncscmid();
			ScmBaseInfoVO scmvo= this.scmBaseInfoService.selectById(scmid);
			Double Scmintrt=scmvo.getScmIntrt().doubleValue();//报价利率
			if(null==Scmintrt || Scmintrt==0){
				Scmintrt=scmvo.getIrtBs().doubleValue()*(1+scmvo.getBsFlotupRto().doubleValue());
			}
             Date transdate=prjvo.getTranstm();
             // list2：还款表明细；Scmintrt：报价利率、fstpyamt：首付款金额
			Double rs=this.getdura(list2,Scmintrt,Double.parseDouble(fstpyamt),transdate);
			result.setData(rs);
			return result;
		}
		
		/**
		 * 加载金融机构收款户选择框
		 * @param request
		 * @param response
		 * @return
		 */
		@RequestMapping(value="/initRecvList.do" ,method = {RequestMethod.GET})
		public @ResponseBody  List<BankAccInfoDTO>  initRecvList(HttpServletRequest request, HttpServletResponse response) {
			String instid = request.getParameter("insId");
			if (StringUtils.isEmpty(instid)) {
				return null;
			}
			BankAccInfoQueryCondition bankAccInfoQC = new BankAccInfoQueryCondition();
			bankAccInfoQC.setFundRasInsId(Long.parseLong(instid));
			bankAccInfoQC.setSysCd(CurrentThreadContext.getCurrentSysCd());
			bankAccInfoQC.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			List<BankAccInfoDTO> banklst = bankAccInfoApiService.searchList(bankAccInfoQC);
			
			return banklst;
		}
		
		/**
		 * 加载狮桥支付账户选择框
		 * @param request
		 * @param response
		 * @return
		 */
		@RequestMapping(value="/initPaybank.do" ,method = {RequestMethod.GET})
		public @ResponseBody  Object  initPayList(HttpServletRequest request, HttpServletResponse response) {
			DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功!");
			SysBkAccInfoQueryCondition qc = new SysBkAccInfoQueryCondition();
			String id = request.getParameter("id");
			qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			
			SysBkAccInfoVO bkAcc = sysBkAccInfoService.selectById(Long.parseLong(id));
			result.setData(bkAcc.getBkNm());
			return result;
		}
		
		/**
		 * 到我的任务管理列表页面
		 */
		@RequestMapping(value = "/toprjFlow.do", method = { RequestMethod.GET })
		public ModelAndView toprjFlow(HttpServletRequest request, HttpServletResponse response) {
			ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/prjFlow");
			view.addObject("id", request.getParameter("id"));
			return view;
		}
		
		/**
		 * 初始化待办管理列表 本查询条件不加入当前人作为查询条件,就是说可以查询出来所有的任务,包括未设置处理人的任务
		 */
		@SuppressWarnings("unchecked")
		@RequestMapping(value = "/initprjFlowList.do", method = { RequestMethod.GET })
		@ResponseBody
		public Object initFriBaseFlowList(HttpServletRequest request, HttpServletResponse response) {
			String currentPage = request.getParameter("page");
			String pageSize = request.getParameter("pagesize");

			String id = request.getParameter("id");

			Pager page = new Pager();
			if (StringUtils.isNotEmpty(currentPage)) {
				page.setCurrentPage(Integer.parseInt(currentPage));
			}

			if (StringUtils.isNotEmpty(currentPage)) {
				page.setEveryPage(Integer.parseInt(pageSize));
			}

			FriBaseInfoQueryCondition condition = new FriBaseInfoQueryCondition();

			condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			condition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			condition.setId(Long.valueOf(id));

			page.setCondition(condition);

			Pager pager = this.fncPrjBscInfoService.searchFlowPageById(page);
			List<FriBaseFlowDTO> list = (List<FriBaseFlowDTO>) pager.getResultList();
			List<FriBaseFlowVO> voList = FriBaseFlowVOTransform.toVOList(list);

			// // 根据流程编号得到一条流程信息
			// for (FriBaseFlowVO friBaseFlowVO : voList) {
			//
			// FlowQueryCondition flowQueryCondition = new FlowQueryCondition();
			// flowQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());
			// flowQueryCondition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			// flowQueryCondition.setProcNo(friBaseFlowVO.getpNo());
			// page.setCondition(flowQueryCondition);
			//
			// Pager flowMyTaskPager = this.flowService.searchTaskRecordManagePage(page, CurrentThreadContext.getCurrentUserId(), "");
			// List<FlowMyTaskVO> flowMyTasklist = (List<FlowMyTaskVO>) flowMyTaskPager.getResultList();
			// if (CollectionUtils.isNotEmpty(flowMyTasklist)) {
			// friBaseFlowVO.setFlowMyTaskVo(flowMyTasklist.get(0));
			// }
			// }

			ListPageVO<FriBaseFlowVO> listPage = new ListPageVO<FriBaseFlowVO>(voList, pager.getTotalCount());
			BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
			return listPage;
		}
	//=================================================工具类===================================
	/*
	 * excel  导入
	 */
	  public  DataResultVO parseExcel(InputStream fis,DataResultVO result,Long id) {  
	        List<Map<String, String>> data = new ArrayList<Map<String, String>>();
	        List<FncPrjPayPlanVO> list = new ArrayList<FncPrjPayPlanVO>();
	        int num=0;
	        try {  
	            HSSFWorkbook book = new HSSFWorkbook(fis);  
	            HSSFSheet sheet = book.getSheetAt(0);  
	            int firstRow = sheet.getFirstRowNum();  
	            int lastRow = sheet.getLastRowNum();  
	            //除去表头和第一行  
//		          ComnDao dao = SysBeans.getComnDao(); 
	            
	            this.fncPrjPayPlanService.removeById(id);
	            for(int i =5; i<lastRow+1; i++) {  
	                Map map = new HashMap();  
	                  
	                HSSFRow row = sheet.getRow(i);  
	                int firstCell = row.getFirstCellNum();  
	                int lastCell = row.getLastCellNum(); 
	                //===========================================赋值====================
	                FncPrjPayPlanVO vo = new FncPrjPayPlanVO();
	                HSSFCell cell;
	                
	                double pdMun=0;
	                Date imputDate;
	                Date repayDate;
	                double rental=0;
	                double capital=0;
	                double interest=0;
	                double otherChar=0;
	                double overColl=0;
	                double reCapital=0;
	                Date reReturnTm;
	                cell= sheet.getRow(i).getCell(0) ;
	                if(cell !=null){
	                 pdMun = cell.getNumericCellValue();
	                 vo.setProjId(id);
	                 vo.setPdMun((long)pdMun);
	              
	                 cell= sheet.getRow(i).getCell(1) ;
	               
		                if(cell !=null  && !cell.toString().equals("")){    	 
		                	imputDate = cell.getDateCellValue();
		                	vo.setImputDate(imputDate);
		                }
		                cell= sheet.getRow(i).getCell(2) ;
		                if(cell !=null  && !cell.toString().equals("") ){
		                	repayDate = cell.getDateCellValue();	 
		                	vo.setRepayDate(repayDate);
		                }
		                cell= sheet.getRow(i).getCell(3) ;
		                if(cell !=null  && !cell.toString().equals("") ){
		                	
		                	rental = Double.parseDouble(cell.toString())	;
		                	vo.setRental(rental);
		                }
		                cell= sheet.getRow(i).getCell(4) ;
		                if(cell !=null){
		                	//  cell.setCellType(cell.CELL_TYPE_NUMERIC);
		                	capital =Double.parseDouble(cell.toString())	;// cell.getNumericCellValue();	
		                	vo.setCapital(capital);
		                }
		                cell= sheet.getRow(i).getCell(5) ;
		                if(cell !=null  && !cell.toString().equals("") ){
		                	//  cell.setCellType(cell.CELL_TYPE_NUMERIC);
		                	interest =Double.parseDouble(cell.toString())	;// cell.getNumericCellValue();	
		                	vo.setInterest(interest);
		                }
		                cell= sheet.getRow(i).getCell(6) ;
		                if(cell !=null && !cell.toString().equals("") ){
		                	//  cell.setCellType(cell.CELL_TYPE_NUMERIC);
		                	otherChar =Double.parseDouble(cell.toString())	;// cell.getNumericCellValue();	  
		                	vo.setOtherChar(otherChar);
		                }
		                cell= sheet.getRow(i).getCell(7) ;
		                if(cell !=null  && !cell.toString().equals("") ){
		                	//  cell.setCellType(cell.CELL_TYPE_NUMERIC);
		                	overColl =Double.parseDouble(cell.toString())	;// cell.getNumericCellValue();	
		                	vo.setOverColl(overColl);
		                }
		                cell= sheet.getRow(i).getCell(8) ;
		                if(cell !=null  && !cell.toString().equals("") ){
		                	//  cell.setCellType(cell.CELL_TYPE_NUMERIC);
		                	reCapital =Double.parseDouble(cell.toString())	;//  cell.getNumericCellValue();	
		                	vo.setReCapital(reCapital);
		                }
		                cell= sheet.getRow(i).getCell(9) ;
		                if(cell !=null  && !cell.toString().equals("") ){
		                	reReturnTm = cell.getDateCellValue();	 
		                	vo.setReReturnTm(reReturnTm);
		                }
	                if(vo.getPdMun()>0){
	                	BaseLogUtils.info(logger, "parseExcel", "vo:" +vo, CurrentThreadContext.getCurrentUserName());
	                	this.fncPrjPayPlanService.add(vo);	
	                	num++;
	                }
	                
	           
	                }

	               //===========================================   
	               
	               
	            }  
	             FncPrjBscInfoVO fpivo=new FncPrjBscInfoVO();
	             fpivo.setId(id);
	             fpivo.setTransst(1);
	             fpivo.setPayplanli(num+"");
	             this.fncPrjBscInfoService.modify(fpivo);
	        } catch (IOException e) {
	        	result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.error(logger, "parseExcel", "错误[Exception] -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
				e.getStackTrace();
	          
	        }  
	        result.setData(num+"");
	        return result;  
      }
	  
	  public  void export(String excelName, String sheetName,String[] headers,String[] ds_titles,int[] ds_format,int[] widths, List<Map<String,Object>> data ,HttpServletRequest request, HttpServletResponse response) throws IOException {  
	      //  HttpSession session = request.getSession();    
	      //  session.setAttribute("state", null);    
	        if(widths==null){  
	              widths = new int[ds_titles.length];  
	              for(int i=0;i<ds_titles.length;i++){  
	                  widths[i]=t_width;  
	              }  
	          }  
	          if(ds_format==null){  
	              ds_format = new int[ds_titles.length];  
	              for(int i=0;i<ds_titles.length;i++){  
	                  ds_format[i]=1;  
	              }  
	          }  
	           //设置文件名  
	            String fileName = "";  
	            if(StringUtils.isNotEmpty(excelName)){  
	                fileName = excelName;  
	            }  
	            //创建一个工作薄  
	            HSSFWorkbook wb = new HSSFWorkbook();  
	            //创建一个sheet  
	            HSSFSheet  sheet = wb.createSheet(StringUtils.isNotEmpty(sheetName)?sheetName:"excel");  
	            //创建表头，如果没有跳过  
	            int headerrow = 0;  
	            if(headers!=null){  
	                HSSFRow  row = sheet.createRow(headerrow);  
	                //表头样式  
	                HSSFCellStyle style = wb.createCellStyle();    
	                HSSFFont font = wb.createFont();  
	                font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);  
	                font.setFontName(t_excelfont);  
	                font.setFontHeightInPoints((short) 11);  
	                style.setFont(font);  
	                style.setAlignment(HSSFCellStyle.ALIGN_CENTER);    
	                style.setBorderBottom(HSSFCellStyle.BORDER_THIN);  
	                style.setBorderLeft(HSSFCellStyle.BORDER_THIN);  
	                style.setBorderRight(HSSFCellStyle.BORDER_THIN);  
	                style.setBorderTop(HSSFCellStyle.BORDER_THIN);  
	                 for (int i = 0; i < headers.length; i++) {    
	                    sheet.setColumnWidth((short)i,(short)widths[i]);   
	                    HSSFCell cell = row.createCell(i);    
	                    cell.setCellValue(headers[i]);    
	                    cell.setCellStyle(style);    
	                }    
	                headerrow++;  
	            }  
	            //表格主体  解析list  
	            if(data != null){  
	                List styleList = new ArrayList();  
	                  
	                for (int i = 0; i <ds_titles.length; i++) {  //列数  
	                    HSSFCellStyle style = wb.createCellStyle();    
	                    HSSFFont font = wb.createFont();  
	                    font.setFontName(t_excelfont);  
	                    font.setFontHeightInPoints((short) 10);  
	                    style.setFont(font);  
	                    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);  
	                    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);  
	                    style.setBorderRight(HSSFCellStyle.BORDER_THIN);  
	                    style.setBorderTop(HSSFCellStyle.BORDER_THIN);  
	                    if(ds_format[i]==1){  
	                        style.setAlignment(HSSFCellStyle.ALIGN_LEFT);    
	                    }else if(ds_format[i]==2){  
	                        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);    
	                    }else if(ds_format[i]==3){  
	                        style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);   
	                         //int类型  
	                    }else if(ds_format[i]==4){  
	                        style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);   
	                         //int类型  
	                        style.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));     
	                    }else if(ds_format[i]==5){  
	                        //float类型  
	                        style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);   
	                        style.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));     
	                    }else if(ds_format[i]==6){  
	                        //百分比类型  
	                        style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);   
	                        style.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00%"));    
	                    }  
	                    styleList.add(style);  
	                }  
	                for (int i = 0; i < data.size() ; i++) {  //行数  
	                    HSSFRow  row = sheet.createRow(headerrow);  
	                    Map map = data.get(i);  
	                    for (int j = 0; j <ds_titles.length; j++) {  //列数  
	                         HSSFCell cell = row.createCell(j);    
	                         Object o = map.get(ds_titles[j]);  
	                         if(o==null||"".equals(o)){  
	                             cell.setCellValue("");  
	                         }else if(ds_format[j]==4){  
	                             //int  
	                             cell.setCellValue((Long.valueOf((map.get(ds_titles[j]))+"")).longValue());   
	                         }else if(ds_format[j]==5|| ds_format[j]==6){  
	                             //float  
	                             cell.setCellValue((Double.valueOf((map.get(ds_titles[j]))+"")).doubleValue());   
	                         }else {  
	                             cell.setCellValue(map.get(ds_titles[j])+"");   
	                         }  
	                           
	                         cell.setCellStyle((HSSFCellStyle)styleList.get(j));    
	                    }  
	                    headerrow++;  
	                }  
	            }  
	             
	            fileName=fileName+".xls";  
	            String filename = "";  
	            try{  
	               filename =encodeChineseDownloadFileName(request,fileName);  
	            }catch(Exception e){  
	                e.printStackTrace();  
	            }  
//	          final String userAgent = request.getHeader("USER-AGENT");  
//	            if(userAgent.indexOf( "MSIE")!=-1){//IE浏览器  
//	              filename = URLEncoder.encode(fileName,"UTF8");  
//	            }else if(userAgent.indexOf( "Mozilla")!=-1){//google,火狐浏览器  
//	              filename = new String(fileName.getBytes(), "ISO8859-1");  
//	            }else{  
//	              filename = URLEncoder.encode(fileName,"UTF8");//其他浏览器  
//	            }  
	              
	            response.setHeader("Content-disposition", filename);  
	            response.setContentType("application/vnd.ms-excel");    
	            response.setHeader("Content-disposition", "attachment;filename="+filename);    
	            response.setHeader("Pragma", "No-cache");  
	            
	            String encoding = getSystemFileCharset();
	            logger.info("export,encoding:"+encoding);
	            if(StringUtils.isNotBlank(encoding)) {
	            	response.setCharacterEncoding(encoding);
	            }
	            
	            OutputStream ouputStream = response.getOutputStream();    
	            wb.write(ouputStream);    
	            ouputStream.flush();    
	            ouputStream.close();  
	         //   session.setAttribute("state", "open");  
	              
	    }  
	      
	  	public static String getSystemFileCharset(){
		    Properties pro = System.getProperties();
		    return pro.getProperty("file.encoding");
		 }
	    /**  
	     * 对文件流输出下载的中文文件名进行编码 屏蔽各种浏览器版本的差异性  
	     * @throws UnsupportedEncodingException   
	     */    
	    public static String encodeChineseDownloadFileName(    
	            HttpServletRequest request, String pFileName) throws Exception {    
	            
	         String filename = null;      
	            String agent = request.getHeader("USER-AGENT");      
	            if (null != agent){      
	                if (-1 != agent.indexOf("Firefox")) {//Firefox      
	                    filename = "=?UTF-8?B?" + (new String(org.apache.commons.codec.binary.Base64.encodeBase64(pFileName.getBytes("UTF-8"))))+ "?=";      
	                }else if (-1 != agent.indexOf("Chrome")) {//Chrome      
	                    filename = new String(pFileName.getBytes(), "ISO8859-1");      
	                } else {//IE7+      
	                    filename = java.net.URLEncoder.encode(pFileName, "UTF-8");      
	                    filename = filename.replace("+", "%20");  
	                }      
	            } else {      
	                filename = pFileName;      
	            }      
	            return filename;     
	    }   
	    
	    
	    public  Double getXirr(List<UpbaaDate> list) throws Exception {    
	            
	    	XirrData Xirr=new XirrData(list);
	    	return Xirr.getXirr();
	    } 
	    
	    public  Double getdura(List<UpbaaDate> list,Double Scmintrt,Double fstpyamt,Date transdate) throws Exception {    
	    	Double x=0.00;
	    	Double y=fstpyamt;
	    	Double intrt=Scmintrt/36000;
	    	for (UpbaaDate upbaaDate : list) {
				//获取与到账日期天
	    		DateFormat dateFormat1 = new java.text.SimpleDateFormat("yyyy-MM-dd");
	    		Date date1 = dateFormat1.parse(upbaaDate.year+"-"+upbaaDate.month+"-"+upbaaDate.day);
	    		 int days = (int) ((date1.getTime() - transdate.getTime()) / (1000*3600*24));
			    // 获取现金流
	    		 Double pay=upbaaDate.payment;
	    		//计算分子
	    		 Double x1=pay*days/Math.pow(1+intrt, days);
	    		 x+=x1;
	    		//计算分母
	    		 Double y1=pay/Math.pow(1+intrt, days);
	    		 y+=y1;
	    		 
	    		 logger.info("dura计算：intrt:"+intrt+"  days:"+days+"  pay:"+pay+"  x:"+x1+"  y:"+y1);
	    	}
	    	
	    	
	    	//XirrData Xirr=new XirrData(list);
	    	return x/y/360;
	    }   
		/**
		 * 加载狮桥支付账户选择框
		 * @param request
		 * @param response
		 * @return
		 */
		@RequestMapping(value="/initPayList2.do" ,method = {RequestMethod.GET,RequestMethod.POST})
		public @ResponseBody  Object  initPayList2(HttpServletRequest request, HttpServletResponse response) {
			String currentPage = request.getParameter("page");
			SysBkAccInfoQueryCondition qc = new SysBkAccInfoQueryCondition();
			String pageSize = request.getParameter("pagesize");
			Pager page = new Pager();
			if (StringUtils.isNotEmpty(currentPage)) {
				page.setCurrentPage(Integer.parseInt(currentPage));
			}

			if (StringUtils.isNotEmpty(pageSize)) {
				page.setEveryPage(Integer.parseInt(pageSize));
			}
			String accNo =request.getParameter("accNo");
			if (StringUtils.isNotEmpty(accNo)) {
				qc.setAccNo(accNo);
			}
			
			String bkNm =request.getParameter("bkNm");
			if (StringUtils.isNotEmpty(bkNm)) {
				qc.setBkNm(bkNm);
			}
			
			qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			page.setCondition(qc);
			Pager pager= sysBkAccInfoService.searchListPage(page);
			List<SysBkAccInfoVO> bkAccList =(List<SysBkAccInfoVO>)pager.getResultList();
			ListPageVO<SysBkAccInfoVO> listPage = new ListPageVO<SysBkAccInfoVO>(bkAccList, pager.getTotalCount());
			return listPage;
		} 
		
		/**
		 * 到列表页面
		 */
		@RequestMapping(value = "/toChooseCompAccPage.do", method = { RequestMethod.GET })
		public ModelAndView toChooseCompAccPage(HttpServletRequest request,
				HttpServletResponse response) {
			logger.info("加载选择账户列表页面.");
			ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/comBankAcc");
			String flag=request.getParameter("flag");
			view.addObject("flag",flag);
			view.addObject("from",request.getParameter("from"));
			return view;
		}
		/**
		 * 更新数据，更新垫款开启
		 * @param fncPrjBscInfoVO
		 * @param request
		 * @param response
		 * @return
		 * @throws Exception
		 */
		@RequestMapping(value = "/modify.do", method = { RequestMethod.GET, RequestMethod.POST })
		@ResponseBody
		public DataResultVO modify(FncPrjBscInfoVO fncPrjBscInfoVO,HttpServletRequest request, HttpServletResponse response) throws Exception {
			String id = request.getParameter("id");
			String splitAccountArray = request.getParameter("splitAccountArray");//分账账户
			DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "成功!");
			try {
				if (fncPrjBscInfoVO.getId()==null) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("主键是空！");
					return result;
				}
				// 分账账户信息
				if(StringUtils.isNotBlank(splitAccountArray)) {
					// 分账账户信息
					JSONArray splitAccountJson = JSONArray.parseArray(splitAccountArray);
					List<FncPrjSplitAccountVO> accountVOList = new ArrayList<>();
					if (splitAccountJson.size() > 0) {
						for (int i = 0; i < splitAccountJson.size(); i++) {
							FncPrjSplitAccountVO accountVO = JSONObject.toJavaObject(splitAccountJson.getJSONObject(i), FncPrjSplitAccountVO.class);
							accountVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
							accountVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
							accountVOList.add(accountVO);
						}
					}
					fncPrjBscInfoVO.setFncPrjSplitAccountList(accountVOList);
				}
				this.fncPrjBscInfoService.modify(fncPrjBscInfoVO);
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo("成功!");
				BaseLogUtils.info(logger, "modify", "更新数据,主键["+id+"].", CurrentThreadContext.getCurrentUserName());
			}catch (BaseException ex) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(ex.getMessage());
				BaseLogUtils.info(logger, "modify", "更新数据失败,主键["+id+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			} catch (Exception ex) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("系统错误!");
				BaseLogUtils.error(logger, "modify", "更新数据失败,主键["+id+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			}
			return result;
		}
		/**
		 * 机构帐号与资产包配置列表页面
		 */
		@RequestMapping(value = "/toInsUserListPage.do", method = { RequestMethod.GET})
		public ModelAndView toInsUserListPage(HttpServletRequest request, HttpServletResponse response) {
			BaseLogUtils.error(logger, "toInsUserListPage", "加载crbaseinfo列表页面.");
			
			ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/insUserListPage");
			return view;
		}
		/**
		 * 到机构帐号与资产包配置新增页面
		 */
		@RequestMapping(value = "/toInsUserAddPage.do", method = { RequestMethod.GET})
		public ModelAndView toInsUserAddPage(HttpServletRequest request, HttpServletResponse response) {
			BaseLogUtils.error(logger, "toInsUserAddPage", "加载到机构帐号与资产包配置新增页面.");
			ModelAndView view=null;
			String flag= request.getParameter("flag");//0查看1修改2新增
			String insUser= request.getParameter("insUser");//用户名
			if ("2".equals(flag)) {
				view = new ModelAndView("/rfbuss/fncprjbscinfo/insUserAddPage");
			}else {
				view = new ModelAndView("/rfbuss/fncprjbscinfo/insUserDetailPage");
			}
			List<FriBaseInfoVO>  friList = null;
			FriBaseInfoQueryCondition friqc = new FriBaseInfoQueryCondition();
//				friqc.setInsUseCd("1");
			friList=friBaseInfoService.searchList(friqc);
			String fncinsid= request.getParameter("fncinsid");
			if (StringUtils.isNotEmpty(fncinsid)) {
				Pager page = new Pager();
				FncPrjBscInfoQueryCondition qc=new FncPrjBscInfoQueryCondition();
				qc.setInsUser(insUser);//用户名
				page.setCondition(qc);
				page.setEveryPage(100);
				qc.setFncinsid(fncinsid);//机构id
				Pager pager = this.fncPrjBscInfoService.searchInsUserListPage(page);
				List<FncPrjBscInfoVO> list = FncPrjBscInfoVOTransform.toVOList((List<FncPrjBscInfoDTO>) pager.getResultList());
				if (list!=null&&list.size()>0) {
					FncPrjBscInfoVO vo=list.get(0);
					for (FriBaseInfoVO ins:friList) {
						if (ins.getId().toString().equals(vo.getFncinsid())) {
							vo.setInstypeNM(ins.getInsTypeCdNm());
						}
					}
					view.addObject("fncPrj",vo);
				}
				view.addObject("fncinsid", fncinsid);
			}
			
			
			view.addObject("frilist",JSON.toJSONString(friList));
			
			view.addObject("flag", flag);
			return view;
		}
		
		/**
		 * 初始化机构帐号与资产包配置
		 * @param request
		 * @param response
		 * @return
		 */
		@SuppressWarnings("unchecked")
		@RequestMapping(value = "/initInsUserList.do", method = { RequestMethod.GET})
		@ResponseBody
		public Object initInsUserList(HttpServletRequest request, HttpServletResponse response) {
			String currentPage = request.getParameter("page");
			String pageSize = request.getParameter("pagesize");
		    
		
			Pager page = new Pager();

			if (StringUtils.isNotEmpty(currentPage)) {
				page.setCurrentPage(Integer.parseInt(currentPage));
			}

			if (StringUtils.isNotEmpty(pageSize)) {
				page.setEveryPage(Integer.parseInt(pageSize));
			}
			FncPrjBscInfoQueryCondition qc=new FncPrjBscInfoQueryCondition();
			String fncinsNM= request.getParameter("fncinsNM");
			if(StringUtils.isNotEmpty(fncinsNM)){
				qc.setFncinsNM(fncinsNM);
			}
			String insUser= request.getParameter("insUser");
			if(StringUtils.isNotEmpty(insUser)){
				qc.setInsUser(insUser);
			}
			String insUserNm= request.getParameter("insUserNm");
			if(StringUtils.isNotEmpty(insUserNm)){
				qc.setInsUserNm(insUserNm);
			}
			page.setCondition(qc);
			
			Pager pager = this.fncPrjBscInfoService.searchInsUserListPage(page);
			List<FncPrjBscInfoVO> list = FncPrjBscInfoVOTransform.toVOList((List<FncPrjBscInfoDTO>) pager.getResultList());
			ListPageVO<FncPrjBscInfoVO> listPage = new ListPageVO<FncPrjBscInfoVO>(list, pager.getTotalCount());
			

			BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
			return listPage;
		}
		/**
		 * 保存机构帐号与资产包配置
		 * @param fncPrjBscInfoVO
		 * @param request
		 * @param response
		 * @return
		 * @throws Exception
		 */
		@RequestMapping(value = "/saveInsUserList.do", method = { RequestMethod.GET, RequestMethod.POST })
		@ResponseBody
		public DataResultVO saveInsUserList(HttpServletRequest request, HttpServletResponse response) throws Exception {
			String ids = request.getParameter("allids");
			DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "成功!");
			try {
				if (StringUtils.isEmpty(ids)) {
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("主键是空！");
					return result;
				}
				String idString=","+request.getParameter("ids");
				String[] allids=ids.split(",");//页面所有项目ID
				String insUser = request.getParameter("insUser");//当前用户
				String insUserFlag = request.getParameter("insUserFlag");
				String isDisAge = request.getParameter("isDisAge"); //是否显示承租人年龄（1：是，0：否）
				String isDisOverdue = request.getParameter("isDisOverdue"); //是否显示逾期数据（1：是，0：否）
				String tempinsUser="";
				for (int i = 0; i < allids.length; i++) {
					//根据项目ID获取未修改前用户信息
					FncPrjBscInfoVO oldPrjVo= fncPrjBscInfoService.selectById(Long.valueOf(allids[i]));
					String insUserStr=oldPrjVo.getInsUser();//融资机构人员,未修改前
					BaseLogUtils.newServiceLogger("oldPrjVo@@=="+JSONObject.toJSONString(oldPrjVo)).info();
					//修改后VO 封装数据
					FncPrjBscInfoVO vo=new FncPrjBscInfoVO();
					vo.setId(Long.valueOf(allids[i]));//用户id
					if (idString.contains(","+allids[i]+",")) {//勾选中的项目id
						vo.setInsUser(insUser);
						//REQ-12686 一个项目可归属两个外部机构账户
						if(StringUtils.isNotBlank(insUser)){//当前新追加新用户
							if(StringUtils.isNotBlank(insUserStr)){//未修改前  用户 
								//比较之前前后拼接逗号   比较此项目之前是否包含新添加的用户
								String cinsUserStr=","+insUserStr+",";
								String cinsUser=","+insUser+",";
								if(!cinsUserStr.contains(cinsUser)){//不包含，用户追加拼接
									tempinsUser=insUserStr+","+insUser;
								}else {//包含 用户信息设置为未修改前 不变
									tempinsUser=insUserStr;
								}
							}else {//此项目之前用户信息为空，直接追加新用户
								tempinsUser=insUser;
							}
						}
						if(StringUtils.isNotBlank(tempinsUser)){
							vo.setInsUser(tempinsUser);
						}
					}else {//未勾选的项目id
						vo.setInsUser("");
						if(StringUtils.isNotBlank(insUserStr)){//判断未修改前用户信息是否包含多个 admin,10000
							//比较之前前后拼接逗号
							String ccinsUserStr=","+insUserStr+",";
							String ccinsUser=","+insUser+",";
							//因为此项目此次未勾选，判断是否包含此次新添加用户信息
							if(!ccinsUserStr.contains(ccinsUser)){//不包含  不用管
								vo.setInsUser(insUserStr);	
							}else {//包含   剔除当前用户信息  admin
								List<String> insUserList = Arrays.asList(insUserStr.split(","));
								StringBuffer sb =new StringBuffer();
								//循环遍历剔除
								if(CollectionUtils.isNotEmpty(insUserList)){
									for(int k=0;k<insUserList.size();k++) {
										String temp=insUserList.get(k);
										if(!temp.equals(insUser)) {
											sb.append(temp);
											sb.append(",");
										}
									}
								}
								if(StringUtils.isNotBlank(sb.toString())) {
									String newSb=sb.toString();
									newSb = newSb.substring(0, newSb.lastIndexOf(',')); 
									vo.setInsUser(newSb);	
								}
							}
						}
					}
					
					vo.setInsUserFlag(insUserFlag);
					vo.setIsDisAge(isDisAge);
					vo.setIsDisOverdue(isDisOverdue);
					BaseLogUtils.info(logger, "saveInsUserList", "saveInsUserList"+JSONObject.toJSONString(oldPrjVo)+"tempinsUser@@"+tempinsUser, CurrentThreadContext.getCurrentUserName());
					this.fncPrjBscInfoService.modify(vo);
					tempinsUser="";//清空临时变量
				}
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo("成功!");
				BaseLogUtils.info(logger, "modify", "更新数据,主键["+ids+"].", CurrentThreadContext.getCurrentUserName());
			}catch (BaseException ex) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(ex.getMessage());
				BaseLogUtils.info(logger, "modify", "更新数据失败,主键["+ids+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			} catch (Exception ex) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("系统错误!");
				BaseLogUtils.error(logger, "modify", "更新数据失败,主键["+ids+"]."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
			}
			return result;
		}
		/**
		 * 资产包检查如果存在占用的支付表 返回ture
		 * @param request
		 * @param response
		 * @return
		 */
		@RequestMapping(value = "/checkPack.do", method = { RequestMethod.POST})
		@ResponseBody
		public Object checkPack(HttpServletRequest request, HttpServletResponse response) {

			String id = request.getParameter("id");
			DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
			if(StringUtils.isEmpty(id)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
				BaseLogUtils.info(logger, "checkPack", SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY, CurrentThreadContext.getCurrentUserName());
				return result;
			}
			//id根据项目主键id获取项目信息
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("不存在占用的支付表");
			///FncPrjBscInfoVO fncPrjBscInfoVO =	this.fncPrjBscInfoService.selectById(Long.parseLong(id));
			//if (fncPrjBscInfoVO !=null && fncPrjBscInfoVO.getAsspackid()!=null) {
				List<FncPrjPayRltvInfoDTO> list=this.assPackInfoApiService.selectIsZyByAssPackId(Long.parseLong(id));
				if (list!=null&&list.size()>0) {
					result.setSuccess(BaseConstant.IS_YESNO_YES);
					result.setInfo("存在占用的支付表");
				}
			//}
			
			BaseLogUtils.info(logger, "checkPack", "查询数据完成. DATA:" + JSONObject.toJSONString(result.getSuccess()), CurrentThreadContext.getCurrentUserName());
			return result;
		}
		/**
		   *    融资管理  菜单【资产使用情况管理】
		 * @author gengchunlan 2020-01-03
		 * @param request
		 * @param response
		 * @return
		 */
		@RequestMapping(value = "/toAssUsePage.do", method = {RequestMethod.GET})
		public ModelAndView toAssUsePage(HttpServletRequest request, HttpServletResponse response){
			logger.info("加载资产使用情况管理页面.");
			ModelAndView view = new ModelAndView("/rfbuss/fncprjbscinfo/assUseListView");
			//获取融资资产种类字典信息
			List<KeyValueVO> astIdlist = this.assPackInfoService.getKvList(FncPrjBaseInfoConstant.FNC_PRJ_AST_ID);
			view.addObject("astIdlist", astIdlist);
			//获取再融资到期提醒字典信息
			List<KeyValueVO> expireList = this.assPackInfoService.getKvList(FncPrjBaseInfoConstant.FNC_PRJ_EXPIRE);
			view.addObject("expireList", expireList);
			return view;
		}
		/**
		   *    融资管理  菜单【资产使用情况管理】初始化列表
		 * @author gengchunlan 2020-01-03
		 * @param request
		 * @param response
		 * @return
		 */
		@SuppressWarnings("unchecked")
		@RequestMapping(value = "/initAssUseList.do", method = { RequestMethod.GET})
		@ResponseBody
		public Object initAssUseList(HttpServletRequest request, HttpServletResponse response) {
			String currentPage = request.getParameter("page");
			String pageSize = request.getParameter("pagesize");
		
			String id = request.getParameter("id");
			String fncprjnm=request.getParameter("fncprjnm");//项目名称
			String financingTypeCd=request.getParameter("financingTypeCd");//再融资状态
			String astCd=request.getParameter("astCd");//融资资产种类
			String paySchNo=request.getParameter("paySchNo");//支付表号
			String isYl=request.getParameter("isYl");//是否预约
			String expireDateStart=request.getParameter("expireDateStart");//到期时间开始
			String expireDateEnd=request.getParameter("expireDateEnd");//到期时间结束
			String isPledge=request.getParameter("isPledge");//到期时间结束
			
			
			Pager page = new Pager();

			if (StringUtils.isNotEmpty(currentPage)) {
				page.setCurrentPage(Integer.parseInt(currentPage));
			}

			if (StringUtils.isNotEmpty(pageSize)) {
				page.setEveryPage(Integer.parseInt(pageSize));
			}
			FncPrjBscInfoQueryCondition qc=new FncPrjBscInfoQueryCondition();
			
			if (StringUtils.isNotEmpty(id)) {
				qc.setId(Long.parseLong(id));
			}
			if (StringUtils.isNotEmpty(fncprjnm)) {
				qc.setFncprjnm(fncprjnm);
			}
			if (StringUtils.isNotEmpty(financingTypeCd)) {
				qc.setFinancingTypeCd(Integer.parseInt(financingTypeCd));
			}
			if (StringUtils.isNotEmpty(astCd)) {
				qc.setAstCd(Integer.parseInt(astCd));
			}
			if (StringUtils.isNotEmpty(paySchNo)) {
				qc.setPaySchNo(paySchNo);
			}
			if (StringUtils.isNotEmpty(isYl)) {
				qc.setIsYl(Integer.parseInt(isYl));
			}
			if (StringUtils.isNotEmpty(expireDateStart)) {
		        qc.setExpireDateStart(DateUtils.formatStringToDate(expireDateStart,DateUtils.YYYY_MM_DD));
			}
			if (StringUtils.isNotEmpty(expireDateEnd)) {
		          qc.setExpireDateEnd(DateUtils.formatStringToDate(expireDateEnd,DateUtils.YYYY_MM_DD));
			}
			if(StringUtils.isNotEmpty(isPledge)) {
				qc.setIsPledge(isPledge);
			}
			qc.setUsrId(CurrentThreadContext.getCurrentUserId());
			page.setCondition(qc);
			Pager pager = this.fncPrjBscInfoService.searchAssUseListPage(page);
			List<FncPrjBscInfoVO> list = FncPrjBscInfoVOTransform.toVOList((List<FncPrjBscInfoDTO>) pager.getResultList());
			this.setAssUsageListWithDicInfo(list);
			ListPageVO<FncPrjBscInfoVO> listPage = new ListPageVO<FncPrjBscInfoVO>(list, pager.getTotalCount());
			BaseLogUtils.info(logger, "initAssUsageList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
			return listPage;
		}
		/**
		   * 设置资产使用情况中关于字典项信息
		 * @param listVO
		 */
		private void setAssUsageListWithDicInfo(List<FncPrjBscInfoVO> listVO) {
			String sysCd=CurrentThreadContext.getCurrentSysCd();
			String orgCd="0000";
			Map<String, String> astIdlist=this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd,FncPrjBaseInfoConstant.FNC_PRJ_AST_ID);		
			if(CollectionUtils.isEmpty(listVO))return;
			for (FncPrjBscInfoVO vo : listVO) {
				//资产占用种类
				if(astIdlist.containsKey(vo.getAstId())){
					vo.setAstNm(astIdlist.get(vo.getAstId()));
				}
			}
		}
	/**
	 * 初始化通道备用列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/initBackList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initBackList(HttpServletRequest request, HttpServletResponse response) {
		String fncPrjId = request.getParameter("fncPrjId");// 再融资项目id
		String mainAccountId = request.getParameter("mainAccountId");// 主账户ID Main_AccountID
		if (StringUtils.isEmpty(fncPrjId)) {
			throw new BaseException(BaseExceptionConstant.COMMON_0001, "再融资项目id不能为空!");
		}
		if (StringUtils.isEmpty(mainAccountId)) {
			throw new BaseException(BaseExceptionConstant.COMMON_0001, "再融资分账主账户id不能为空!");
		}
		List<KeyValueVO> list2 = this.sysDictionaryApiService.getKvList(FriBaseInfoConstant.FNC_PAY_MAY_BACK, CurrentThreadContext.getCurrentSysCd(),
				CurrentThreadContext.getCurrentOrgCd());
		//分账备用账户
		FncPrjSplitAccountQueryCondition sqc = new FncPrjSplitAccountQueryCondition();
		sqc.setFncprjid(Long.parseLong(fncPrjId));
		sqc.setMainAccountId(Long.parseLong(mainAccountId));
		List<FncPrjSplitAccountVO>  splitList = fncPrjSplitAccountService.searchList(sqc);
		//设置数据字典
		setDic(splitList,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
		ListPageVO<FncPrjSplitAccountVO> listPage = new ListPageVO<FncPrjSplitAccountVO>(splitList, splitList.size());
		BaseLogUtils.newServiceLogger("initBackList===修改数据,initBackList:" + JSON.toJSONString(listPage)).info();
		return listPage;
	}
	/**
	 * 设置数据字典 支付通道备用 REF0050
	 * @param list
	 * @param sysCd
	 * @param orgCd
	 */
	public void setDic(List<FncPrjSplitAccountVO> list, String sysCd, String orgCd) {
		List<KeyValueVO> list2 = this.sysDictionaryApiService.getKvList(FriBaseInfoConstant.FNC_PAY_MAY_BACK, sysCd,
				orgCd);
		if (list != null && list.size() > 0) {
			for (FncPrjSplitAccountVO dto : list) {
				// 支付通道名称
				for (int i = 0; i < list2.size(); i++) {
					KeyValueVO kv = list2.get(i);
					if (kv.getKey().equals(dto.getPayMay())) {
						dto.setPayMayNm(kv.getValue());
						break;
					}
				}
			}
		}
	}
	/**
	 * 保存备用通道信息 【修改/新增 项目信息 --新增/编辑 备用通道】
	 */
	@RequestMapping(value = "/saveBackPayWay.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object saveBackPayWay(HttpServletRequest request, HttpServletResponse response) throws Exception {

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功!");
		String fncPrjId = request.getParameter("fncPrjId");//再融资项目信息
		String mainAccountId = request.getParameter("mainAccountId");// 备用主账户信息
		String backJson = request.getParameter("backJson");// 备用账户信息列表
		try {
			if (StringUtils.isEmpty(fncPrjId)) {
				throw new BaseException(BaseExceptionConstant.COMMON_0001, "再融资项目id不能为空!");
			}
			if (StringUtils.isEmpty(mainAccountId)) {
				throw new BaseException(BaseExceptionConstant.COMMON_0001, "主账户信息不能为空!");
			}
			
			// 备用账户信息列表
			net.sf.json.JSONArray arrayRl = net.sf.json.JSONArray.fromObject(backJson);//备用信息账户列表
			List<FncPrjSplitAccountVO> rlList = net.sf.json.JSONArray.toList(arrayRl, FncPrjSplitAccountVO.class);
			BaseLogUtils.newServiceLogger("===saveBackPayWayRl[" + JSON.toJSONString(arrayRl) + "].").info();
			List<FncPrjSplitAccountVO> addList = new ArrayList<>();// 新增list
			List<FncPrjSplitAccountVO> modifyList = new ArrayList<>();// 修改list
			if (CollectionUtils.isNotEmpty(rlList)) {
				for (FncPrjSplitAccountVO rlVo : rlList) {
					if (rlVo != null) {
						if (StringUtils.isNotEmpty(rlVo.getId())) {
							rlVo.setMdfTm(new Date());
							rlVo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
							fncPrjSplitAccountService.modify(rlVo);
							modifyList.add(rlVo);
						} else {
							rlVo.setCrtTm(new Date());
							rlVo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
							rlVo.setMainAccountId(Long.parseLong(mainAccountId));
							rlVo.setFncprjid(Long.parseLong(fncPrjId));
							fncPrjSplitAccountService.add(rlVo);
							addList.add(rlVo);
						}
					}
				}
			} // end 备用账户信息列表
			BaseLogUtils.newServiceLogger("===saveBackPayWayRl addList[" + JSON.toJSONString(addList) + "]."
					+ "modifyList" + JSON.toJSONString(modifyList)+"@@mainAccountId=="+mainAccountId).info();
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			result.setInfo("更新成功!");
			BaseLogUtils.newServiceLogger("===saveBackPayWay修改数据成功,entity[" + JSON.toJSONString(backJson) + "]."+"@mainAccountId="+mainAccountId).info();
		} catch (BaseException ex) {
			ex.printStackTrace();
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newServiceLogger("===saveBackPayWay修改数据失败,backJson[" +JSON.toJSONString(backJson) + "]." +"@mainAccountId="+mainAccountId+ ex.getMessage()).info();
		} catch (Exception ex) {
			ex.printStackTrace();
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误");
			BaseLogUtils.newServiceLogger("===saveBackPayWay修改数据失败,backJson[" +JSON.toJSONString(backJson) + "]." +"@mainAccountId="+mainAccountId+ ex.getMessage()).info();
		}
		return result;
	}
	/**
	 * 删除备用通道信息 【修改/新增 项目信息 --新增/编辑 删除备用通道】
	 */
	@RequestMapping(value = "/updateBackPayWayById.do", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public Object updateBackPayWayById(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "成功!");
		// 获取数据
		String rl_split_id = request.getParameter("rl_split_id");//主要人员信息id
		if (StringUtils.isNotBlank(rl_split_id)) {
		} else {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("业务主键不允许为空失败!");
			return result;
		}
		BaseLogUtils.newServiceLogger("updateBackPayWayById===作废rl_split_id:" + rl_split_id).info();
		// 封装数据
		FncPrjSplitAccountVO rlSplitVO = new FncPrjSplitAccountVO();
		rlSplitVO.setId(Long.parseLong(rl_split_id));
		rlSplitVO.setIsdel(BaseConstant.IS_YESNO_YES);;
		rlSplitVO.setMdfTm(new Date());
		rlSplitVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		// 保存
		try {
			fncPrjSplitAccountService.modify(rlSplitVO);
			result.setSuccess(BaseConstant.IS_YESNO_YES);
			result.setInfo("操作成功!");
			BaseLogUtils.info(logger, "updateRlPsnbyId", "作废数据 , rl_split_id:" + rl_split_id, CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("操作失败!");
			BaseLogUtils.newServiceLogger("updateBackPayWayById===作废数据,rl_split_id:" + rl_split_id).error(LogExceptionEnum.DATA_CODE_0201);;
		}
		return result;
	}
}
